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

QueryCache::delete()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 9
ccs 0
cts 7
cp 0
rs 10
cc 3
nc 3
nop 2
crap 12
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