Passed
Push — master ( d7f029...202469 )
by Jean-Christophe
15:08
created

QueryCache   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
wmc 5
eloc 13
c 0
b 0
f 0
dl 0
loc 21
ccs 6
cts 14
cp 0.4286
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 9 3
A store() 0 7 2
1
<?php
2
3
namespace Ubiquity\cache\database;
4
5
/**
6
 * Ubiquity\cache\database$QueryCache
7
 * This class is part of Ubiquity
8
 *
9
 * @author jcheron <[email protected]>
10
 * @version 1.0.2
11
 *
12
 */
13
class QueryCache extends DbCache {
14
15 7
	public function store($tableName, $condition, $result) {
16 7
		$key = $this->getKey ( $tableName, $condition );
17 7
		$this->memoryCache [$key] = $result;
18 7
		if ($this->storeDeferred) {
19
			$this->toStore [] = $key;
20
		} else {
21 7
			$this->cache->store ( $key, $result );
22
		}
23 7
	}
24
25
	public function delete($tableName, $condition) {
26
		$key = $this->getKey ( $tableName, $condition );
27
		if ($this->cache->exists ( $key )) {
28
			if (isset ( $this->memoryCache [$key] )) {
29
				unset ( $this->memoryCache [$key] );
30
			}
31
			return $this->cache->remove ( $key );
32
		}
33
		return false;
34
	}
35
}
36