KVStorage에 reset추가

This commit is contained in:
2018-05-12 05:32:18 +09:00
parent 798be5fd5c
commit c5d008ec47
+16 -1
View File
@@ -4,7 +4,7 @@ namespace sammo;
class KVStorage{
private $storNamespace;
private $cacheData = null;
public function __construct(string $storNamespace, bool $cacheMode=false){
$this->storNamespace = $storNamespace;
if($cacheMode){
@@ -30,6 +30,13 @@ class KVStorage{
return $this;
}
public function resetValues():self{
if($this->cacheData !== null){
$this->cacheData = [];
}
return $this->resetDBNamespace();
}
public function invalidateCacheValue($key):self{
if($this->cacheData === null){
return $this;
@@ -215,4 +222,12 @@ class KVStorage{
]);
return $this;
}
private function resetDBNamespace():self{
$db = DB::db();
$db->delete('storage', [
'namespace'=>$this->storNamespace
]);
return $this;
}
}