Passed
Push — master ( bd3cb9...127ddb )
by Jean-Christophe
17:45
created

MemoryCache::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Ubiquity\cache\database;
4
5
/**
6
 * Ubiquity\cache\database$MemoryCache
7
 * This class is part of Ubiquity
8
 *
9
 * @author jcheron <[email protected]>
10
 * @version 1.0.1
11
 *
12
 */
13
class MemoryCache extends DbCache {
14
	/**
15
	 *
16
	 * @var array
17
	 */
18
	protected $memoryCache;
19
20
	public function __construct() {
21
	}
22
23 9
	public function fetch($tableName, $condition) {
24 9
		$key = $this->getKey ( $tableName, $condition );
25 9
		if (isset ( $this->memoryCache [$key] )) {
26
			return $this->memoryCache [$key];
27
		}
28 9
		return false;
29
	}
30
31 9
	public function store($tableName, $condition, $result) {
32 9
		$this->memoryCache [$this->getKey ( $tableName, $condition )] = $result;
33
	}
34
35
	public function delete($tableName, $condition) {
36
		$key = $this->getKey ( $tableName, $condition );
37
		if (isset ( $this->memoryCache [$key] )) {
38
			unset ( $this->memoryCache [$key] );
39
			return true;
40
		}
41
		return false;
42
	}
43
}
44