1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 14:16:32 +02:00

[1.7.0] Add DefinitionCache decorators, implement Memory decorator

- Move serialization responsibility to Config
- Create DefinitionCacheFactory
- Implement Null definition cache

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1117 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-05-29 20:21:33 +00:00
parent d1187ed331
commit 002395de09
16 changed files with 509 additions and 75 deletions

View File

@@ -1,11 +1,13 @@
<?php
require_once 'HTMLPurifier/DefinitionCache/Serializer.php';
require_once 'HTMLPurifier/DefinitionCache/Null.php';
require_once 'HTMLPurifier/DefinitionCache/Decorator.php';
/**
* Abstract class representing Definition cache managers that implements
* useful common methods and is a factory.
* @note The configuration object is transformed into the key used by the cache
* @todo Get some sort of versioning variable so the library can easily
* invalidate the cache with a new version
* @todo Make the test runner cache aware and allow the user to easily
@@ -33,9 +35,9 @@ class HTMLPurifier_DefinitionCache
* @param Instance of HTMLPurifier_Config
*/
function generateKey($config) {
$version = $config->version;
$revision = $config->revision;
return $version . '-' . $revision . '-' . md5(serialize($config->getBatch($this->type)));
return $config->version . '-' . // possibly replace with function calls
$config->revision . '-' .
$config->getBatchSerial($this->type);
}
/**
@@ -52,17 +54,6 @@ class HTMLPurifier_DefinitionCache
return true;
}
/**
* Factory method that creates a cache object based on configuration
* @param $name Name of definitions handled by cache
* @param $config Instance of HTMLPurifier_Config
*/
function create($name, $config) {
// only one implementation as for right now, $config will
// be used to determine implementation
return new HTMLPurifier_DefinitionCache_Serializer($name);
}
/**
* Checks if a definition's type jives with the cache's type
* @note Throws an error on failure