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

DbCache   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 2
cbo 2
dl 0
loc 31
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getKey() 0 3 1
A __construct() 0 5 1
store() 0 1 ?
fetch() 0 1 ?
A clear() 0 3 1
A remove() 0 3 1
A setActive() 0 3 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