Elgg  Version 2.3
InMemory.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg\Cache\Pool;
3 
5 use Stash;
6 
18 final class InMemory implements Pool {
22  private $values = array();
23 
25  public function get($key, callable $callback = null, $default = null) {
26  assert(is_string($key) || is_int($key));
27 
28  if (!array_key_exists($key, $this->values)) {
29  if (!$callback) {
30  return $default;
31  }
32  $this->values[$key] = call_user_func($callback);
33  }
34  return $this->values[$key];
35  }
36 
38  public function invalidate($key) {
39  assert(is_string($key) || is_int($key));
40 
41  unset($this->values[$key]);
42  }
43 
45  public function put($key, $value) {
46  assert(is_string($key) || is_int($key));
47 
48  $this->values[$key] = $value;
49  }
50 }
$value
Definition: longtext.php:42
$default
Definition: checkbox.php:34
$key
Definition: summary.php:34
An in-memory implementation of a cache pool.
Definition: InMemory.php:18
put($key, $value)
Definition: InMemory.php:45
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:5