Bouncy Melons 0.1
declarative style orm
Cache.php
Go to the documentation of this file.
1 <?php
2 
3 namespace bm;
4 
8 class Cache {
9 
10  private $items = [];
11 
12  public function notcached($class, $key) {
13  $className = $class;
14  if(is_object($class)) {
15  $className = get_class($class);
16  }
17  if(empty($this->items[$className])) {
18  return true;
19  }
20  if(!isset($this->items[$className][$key])) {
21  return true;
22  }
23  return false;
24  }
25 
26  public function cached($class, $key) {
27  return !$this->notcached($class, $key);
28  }
29 
30 
31  public function get($class, $key) {
32  $className = $class;
33  if(is_object($class)) {
34  $className = get_class($class);
35  }
36 // var_dump([get_class($class), $key, $this->items]);
37  return @$this->items[$className][$key];
38  }
39 
40  public function set($class, $key,$value){
41  $className = $class;
42  if(is_object($class)) {
43  $className = get_class($class);
44  }
45  $this->items[$className][$key] = $value;
46  }
47 
48 }
49 
notcached($class, $key)
Definition: Cache.php:12
cached($class, $key)
Definition: Cache.php:26