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 HTMLPurifier_DefinitionCache_Decorator
13 protected $definitions;
18 public $name = 'Memory';
21 * @return HTMLPurifier_DefinitionCache_Decorator_Memory
23 public function copy()
25 return new HTMLPurifier_DefinitionCache_Decorator_Memory();
29 * @param HTMLPurifier_Definition $def
30 * @param HTMLPurifier_Config $config
33 public function add($def, $config)
35 $status = parent::add($def, $config);
37 $this->definitions[$this->generateKey($config)] = $def;
43 * @param HTMLPurifier_Definition $def
44 * @param HTMLPurifier_Config $config
47 public function set($def, $config)
49 $status = parent::set($def, $config);
51 $this->definitions[$this->generateKey($config)] = $def;
57 * @param HTMLPurifier_Definition $def
58 * @param HTMLPurifier_Config $config
61 public function replace($def, $config)
63 $status = parent::replace($def, $config);
65 $this->definitions[$this->generateKey($config)] = $def;
71 * @param HTMLPurifier_Config $config
74 public function get($config)
76 $key = $this->generateKey($config);
77 if (isset($this->definitions[$key])) {
78 return $this->definitions[$key];
80 $this->definitions[$key] = parent::get($config);
81 return $this->definitions[$key];