Completed
Push — master ( 25576f...77f108 )
by Jean-Christophe
02:06
created

DbCache::getKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace micro\cache\database;
3
4
use micro\cache\ArrayCache;
5
use micro\cache\CacheManager;
6
7
abstract class DbCache{
8
	protected $cache;
9
	protected $config;
10
	public static $active=false;
11
12
	protected function getKey($query){
13
		return \md5($query);
14
	}
15
16
	public function __construct(){
17
		$cacheDirectory=ROOT.DS.CacheManager::getCacheDirectory().DS."queries";
18
		$this->cache=new ArrayCache($cacheDirectory,".query");
19
		self::$active=true;
20
	}
21
22
	abstract public function store($tableName,$condition,$result);
23
24
	abstract public function fetch($tableName,$condition);
25
26
	public function clear(){
27
		$this->cache->clear();
28
	}
29
30
	public function remove($element){
31
		$this->cache->remove($element);
32
	}
33
34
	public function setActive($value=true){
35
		self::$active=$value;
36
	}
37
}
38