Test Failed
Push — master ( 18f7ca...2e2fb6 )
by Jean-Christophe
10:31
created

MemoryCache::fetch()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 4
c 2
b 1
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 2
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
	public function fetch($tableName, $condition) {
24
		$key = $this->getKey ( $tableName, $condition );
25
		if (isset ( $this->memoryCache [$key] )) {
26
			return $this->memoryCache [$key];
27
		}
28
		return false;
29
	}
30
31
	public function store($tableName, $condition, $result) {
32
		$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