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

QueryCache   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 20
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fetch() 0 6 2
A store() 0 3 1
A delete() 0 6 2
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