Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
ElggStaticVariableCache.php
Go to the documentation of this file.
1 <?php
16  private static $__cache;
17 
27  public function __construct($namespace = 'default') {
28  $this->setNamespace($namespace);
29  $this->clear();
30  }
31 
40  public function save($key, $data) {
41  $namespace = $this->getNamespace();
42 
43  \ElggStaticVariableCache::$__cache[$namespace][$key] = $data;
44 
45  return true;
46  }
47 
57  public function load($key, $offset = 0, $limit = null) {
58  $namespace = $this->getNamespace();
59 
60  if (isset(\ElggStaticVariableCache::$__cache[$namespace][$key])) {
61  return \ElggStaticVariableCache::$__cache[$namespace][$key];
62  }
63 
64  return false;
65  }
66 
74  public function delete($key) {
75  $namespace = $this->getNamespace();
76 
77  unset(\ElggStaticVariableCache::$__cache[$namespace][$key]);
78 
79  return true;
80  }
81 
87  public function clear() {
88  $namespace = $this->getNamespace();
89 
90  if (!isset(\ElggStaticVariableCache::$__cache)) {
91  \ElggStaticVariableCache::$__cache = array();
92  }
93 
94  \ElggStaticVariableCache::$__cache[$namespace] = array();
95  }
96 }
clear()
Clears the cache for a particular namespace.
$data
Definition: opendd.php:13
if(!$count) $offset
Definition: pagination.php:26
getNamespace()
Get the namespace currently defined.
save($key, $data)
Save a key.
$limit
Definition: userpicker.php:38
$key
Definition: summary.php:34
setNamespace($namespace="default")
Set the namespace of this cache.
load($key, $offset=0, $limit=null)
Load a key.
__construct($namespace= 'default')
Create the variable cache.