-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
134 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,13 @@ | |
* Email: [email protected] | ||
*/ | ||
|
||
return []; | ||
return [ | ||
// 路由前缀 | ||
'prefix' => '_purple', | ||
|
||
// 表名/redis key名 | ||
'table' => 'purple', | ||
|
||
// 存储方式 | ||
'storage' => 'mysql' | ||
]; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* Email: [email protected] | ||
*/ | ||
|
||
namespace Purple\Collections; | ||
namespace Purple\Collectors; | ||
|
||
|
||
use Illuminate\Foundation\Application; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
* Email: [email protected] | ||
*/ | ||
|
||
namespace Purple\Collections; | ||
namespace Purple\Collectors; | ||
|
||
use Illuminate\Foundation\Application; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* Email: [email protected] | ||
*/ | ||
|
||
namespace Purple\Collections; | ||
namespace Purple\Collectors; | ||
|
||
|
||
use Illuminate\Foundation\Application; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,38 +3,36 @@ | |
* Created by PhpStorm. | ||
* User: Krasen | ||
* Date: 16/5/17 | ||
* Time: 17:23 | ||
* Time: 16:32 | ||
* Email: [email protected] | ||
*/ | ||
|
||
namespace Purple\Adapter; | ||
namespace Purple\Storage; | ||
|
||
use DB; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Purple\Request\Request; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
|
||
class MySQL extends Model implements AdapterInterface | ||
class MySQLStorage extends Model implements StorageInterface | ||
{ | ||
use StorageTrait; | ||
|
||
protected $table = 'purple'; | ||
|
||
protected $fillable = ['uuid', 'uri', 'content', 'time']; | ||
|
||
public function store(Request $request) | ||
public function retrieve($id) | ||
{ | ||
try { | ||
self::create($request->toArray()); | ||
}catch (\Exception $e) { | ||
throw new \Exception($e->getMessage()); | ||
} | ||
|
||
return unserialize(DB::table('purple')->where('uuid', $id)->value('content')); | ||
} | ||
|
||
public function retrieve($id) | ||
public function store(Request $request) | ||
{ | ||
return DB::table('purple')->where('uuid', $id)->first(); | ||
self::create($request->toArray()); | ||
} | ||
|
||
public function clear() | ||
public function purge() | ||
{ | ||
DB::table('purple')->truncate(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: krasen | ||
* Date: 6/5/2016 | ||
* Time: 3:28 PM | ||
*/ | ||
|
||
namespace Purple\Storage; | ||
|
||
use Cache; | ||
use Purple\Request\Request; | ||
|
||
class RedisStorage implements StorageInterface | ||
{ | ||
use StorageTrait; | ||
|
||
public function retrieve($id) | ||
{ | ||
/** | ||
* @var $config \Illuminate\Config\Repository | ||
*/ | ||
$config = $this->app['config']; | ||
$table = $config->get('purple.table', 'purple'); | ||
|
||
$client = Cache::store('redis')->connection(); | ||
$values = unserialize($client->hget($table, $id)); | ||
return unserialize($values['content']); | ||
} | ||
|
||
public function store(Request $request) | ||
{ | ||
/** | ||
* @var $config \Illuminate\Config\Repository | ||
*/ | ||
$config = $this->app['config']; | ||
$table = $config->get('purple.table', 'purple'); | ||
|
||
$client = Cache::store('redis')->connection(); | ||
$client->hset($table, $request->getUuid(), serialize($request->toArray())); | ||
} | ||
|
||
public function purge() | ||
{ | ||
/** | ||
* @var $config \Illuminate\Config\Repository | ||
*/ | ||
$config = $this->app['config']; | ||
$table = $config->get('purple.table', 'purple'); | ||
|
||
Cache::store('redis')->del($table); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.