Ubiquity  2.0.3
php rapid development framework
DbCache.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
8 abstract class DbCache {
9  protected $cache;
10  protected $config;
11  public static $active=false;
12 
13  protected function getKey($query) {
14  return \md5($query);
15  }
16 
17  public function __construct() {
18  $cacheDirectory=ROOT . DS . CacheManager::getCacheDirectory() . DS . "queries";
19  $this->cache=new ArrayCache($cacheDirectory, ".query");
20  }
21 
28  abstract public function store($tableName, $condition, $result);
29 
36  abstract public function fetch($tableName, $condition);
37 
44  abstract public function delete($tableName, $condition);
45 
46  public function clear($matches="") {
47  $this->cache->clear($matches);
48  }
49 
50  public function remove($key) {
51  $this->cache->remove($key);
52  }
53 
54  public function setActive($value=true) {
55  self::$active=$value;
56  }
57 }
fetch($tableName, $condition)
Fetches data stored for the given condition in table.
This class is responsible for storing Arrays in PHP files.
Definition: ArrayCache.php:13
store($tableName, $condition, $result)
Caches the given data with the given key (tableName+md5(condition)).