| Total Complexity | 12 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 74.07% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class TableCache extends DbCache { |
||
| 8 | protected $arrayCache; |
||
| 9 | |||
| 10 | 5 | public function store($tableName, $condition, $result) { |
|
| 11 | 5 | $exists=$this->getCache($tableName); |
|
| 12 | 5 | $exists[$this->getKey($condition)]=$result; |
|
| 13 | 5 | $this->cache->store($tableName, "return " . UArray::asPhpArray($exists, "array") . ";"); |
|
| 14 | 5 | } |
|
| 15 | |||
| 16 | 5 | public function getCache($tableName) { |
|
| 17 | 5 | if ($this->cache->exists($tableName)) |
|
| 18 | 4 | return $this->cache->fetch($tableName); |
|
| 19 | 2 | return [ ]; |
|
| 20 | } |
||
| 21 | |||
| 22 | 6 | protected function getArrayCache($tableName) { |
|
| 23 | 6 | if (isset($this->arrayCache[$tableName])) |
|
| 24 | return $this->arrayCache[$tableName]; |
||
| 25 | 6 | if ($this->cache->exists($tableName)) { |
|
| 26 | 5 | return $this->arrayCache[$tableName]=$this->cache->fetch($tableName); |
|
| 27 | } |
||
| 28 | 2 | return false; |
|
| 29 | } |
||
| 30 | |||
| 31 | 6 | public function fetch($tableName, $condition) { |
|
| 32 | 6 | if ($cache=$this->getArrayCache($tableName)) { |
|
| 33 | 5 | $key=$this->getKey($condition); |
|
| 34 | 5 | if (isset($cache[$key])) |
|
| 35 | 2 | return $cache[$key]; |
|
| 36 | } |
||
| 37 | 5 | return false; |
|
| 38 | } |
||
| 39 | |||
| 40 | public function delete($tableName, $condition){ |
||
| 46 | } |
||
| 47 | } |
||
| 48 | } |
||
| 49 | } |
||
| 50 |