Elgg  Version 1.11
MemoryPool.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Cache;
3 
4 use Stash;
5 
19 final class MemoryPool implements Pool {
23  private $values = array();
24 
26  public function get($key, callable $callback) {
27  assert(is_string($key) || is_int($key));
28 
29  if (!array_key_exists($key, $this->values)) {
30  $this->values[$key] = call_user_func($callback);
31  }
32  return $this->values[$key];
33  }
34 
36  public function invalidate($key) {
37  assert(is_string($key) || is_int($key));
38 
39  unset($this->values[$key]);
40  }
41 
43  public function put($key, $value) {
44  assert(is_string($key) || is_int($key));
45 
46  $this->values[$key] = $value;
47  }
48 }
$value
Definition: longtext.php:26
$key
Definition: summary.php:34
put($key, $value)
Definition: MemoryPool.php:43