4 * Definition cache decorator class that saves all cache retrievals
5 * to PHP's memory; good for unit tests or circumstances where
6 * there are lots of configuration objects floating around.
8 class HTMLPurifier_DefinitionCache_Decorator_Memory
extends
9 HTMLPurifier_DefinitionCache_Decorator
12 protected $definitions;
13 public $name = 'Memory';
15 public function copy() {
16 return new HTMLPurifier_DefinitionCache_Decorator_Memory();
19 public function add($def, $config) {
20 $status = parent
::add($def, $config);
21 if ($status) $this->definitions
[$this->generateKey($config)] = $def;
25 public function set($def, $config) {
26 $status = parent
::set($def, $config);
27 if ($status) $this->definitions
[$this->generateKey($config)] = $def;
31 public function replace($def, $config) {
32 $status = parent
::replace($def, $config);
33 if ($status) $this->definitions
[$this->generateKey($config)] = $def;
37 public function get($config) {
38 $key = $this->generateKey($config);
39 if (isset($this->definitions
[$key])) return $this->definitions
[$key];
40 $this->definitions
[$key] = parent
::get($config);
41 return $this->definitions
[$key];