Completed
Push — master ( a48513...213d8d )
by Jean-Christophe
01:39
created

QueryCache::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
1
<?php
2
3
namespace Ubiquity\cache\database;
4
5
use Ubiquity\cache\database\DbCache;
6
use Ubiquity\utils\JArray;
7
8
class QueryCache extends DbCache {
9
10
	public function fetch($tableName, $condition) {
11
		$key=$tableName . "." . $this->getKey($condition);
12
		if ($this->cache->exists($key))
13
			return $this->cache->fetch($key);
14
		return false;
15
	}
16
17
	public function store($tableName, $condition, $result) {
18
		$this->cache->store($tableName . "." . $this->getKey($condition), "return " . JArray::asPhpArray($result, "array") . ";");
19
	}
20
21
	public function delete($tableName, $condition){
22
		$key=$tableName . "." . $this->getKey($condition);
23
		if ($this->cache->exists($key))
24
			return $this->cache->remove($key);
25
		return false;
26
	}
27
}
28