KVStorage에 reset추가
This commit is contained in:
+16
-1
@@ -4,7 +4,7 @@ namespace sammo;
|
|||||||
class KVStorage{
|
class KVStorage{
|
||||||
private $storNamespace;
|
private $storNamespace;
|
||||||
private $cacheData = null;
|
private $cacheData = null;
|
||||||
|
|
||||||
public function __construct(string $storNamespace, bool $cacheMode=false){
|
public function __construct(string $storNamespace, bool $cacheMode=false){
|
||||||
$this->storNamespace = $storNamespace;
|
$this->storNamespace = $storNamespace;
|
||||||
if($cacheMode){
|
if($cacheMode){
|
||||||
@@ -30,6 +30,13 @@ class KVStorage{
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function resetValues():self{
|
||||||
|
if($this->cacheData !== null){
|
||||||
|
$this->cacheData = [];
|
||||||
|
}
|
||||||
|
return $this->resetDBNamespace();
|
||||||
|
}
|
||||||
|
|
||||||
public function invalidateCacheValue($key):self{
|
public function invalidateCacheValue($key):self{
|
||||||
if($this->cacheData === null){
|
if($this->cacheData === null){
|
||||||
return $this;
|
return $this;
|
||||||
@@ -215,4 +222,12 @@ class KVStorage{
|
|||||||
]);
|
]);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function resetDBNamespace():self{
|
||||||
|
$db = DB::db();
|
||||||
|
$db->delete('storage', [
|
||||||
|
'namespace'=>$this->storNamespace
|
||||||
|
]);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user