Passed
Push — master ( 01ad3a...c5e11d )
by Jean-Christophe
05:40
created

QueryCache   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 61.53%

Importance

Changes 0
Metric Value
wmc 5
eloc 10
dl 0
loc 18
ccs 8
cts 13
cp 0.6153
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 5 2
A fetch() 0 5 2
A store() 0 2 1
1
<?php
2
3
namespace Ubiquity\cache\database;
4
5
use Ubiquity\utils\base\UArray;
6
7
class QueryCache extends DbCache {
8
9 8
	public function fetch($tableName, $condition) {
10 8
		$key=$tableName . "." . $this->getKey($condition);
11 8
		if ($this->cache->exists($key))
12 2
			return $this->cache->fetch($key);
13 7
		return false;
14
	}
15
16 7
	public function store($tableName, $condition, $result) {
17 7
		$this->cache->store($tableName . "." . $this->getKey($condition), "return " . UArray::asPhpArray($result, "array") . ";");
18 7
	}
19
20
	public function delete($tableName, $condition){
21
		$key=$tableName . "." . $this->getKey($condition);
22
		if ($this->cache->exists($key))
23
			return $this->cache->remove($key);
24
		return false;
25
	}
26
}
27