Fast, light and safe Cache Class
TCache_Lite is a fast, light and safe cache system. It's optimized for file containers. It is fast and safe (because it uses file locking and/or anti-corruption tests).
There are some examples in the 'docs/examples' file Technical choices are described in the 'docs/technical' file
A tutorial is available in english at this url : http://www.pearfr.org/index.php/en/article/cache_lite (big thanks to Pierre-Alain Joye for the translation)
The same tutorial is also available in french at this url : http://www.pearfr.org/index.php/fr/article/cache_lite
Memory Caching is from an original idea of Mike BENOIT <ipso@snappymail.ca>
Located in /I18N/core/TCache_Lite.php (line 47)
Enable / disable automatic serialization
it can be used to save directly datas which aren't strings (but it's slower)
Directory where to put the cache files (make sure to add a trailing slash)
Enable / disable caching
(can be very usefull for the debug of cached scripts)
File name (with path)
Enable / disable fileLocking
(can avoid cache corruption under bad circumstances)
File Name protection
if set to true, you can use any cache id or group name if set to false, it can be faster but cache ids and group names will be used directly in cache file names so be carefull with special characters...
Current cache group
Current cache id
Cache lifetime (in seconds)
Enable / Disable "Memory Caching"
NB : There is no lifetime for memory caching !
Memory caching array
Memory caching counter
Memory caching limit
Enable / Disable "Only Memory Caching" (be carefull, memory caching is "beta quality")
Enable / disable read control
If enabled, a control key is embeded in cache file and this key is compared with the one calculated after the reading.
Type of read control (only if read control is enabled)
Available values are : 'md5' for a md5 hash control (best but slowest) 'crc32' for a crc32 hash control (lightly less safe but faster, better choice) 'strlen' for a length only test (fastest)
Timestamp of the last valid cache
Enable / disable write control (the cache is read just after writing to detect corrupt entries)
Enable write control will lightly slow the cache writing but not the cache reading. Write control can detect some corrupt cache files but maybe it's not a perfect control
Constructor
$options is an assoc. Available options are : $options = array( 'cacheDir' => directory where to put the cache files (string), 'caching' => enable / disable caching (boolean), 'lifeTime' => cache lifetime in seconds (int), 'fileLocking' => enable / disable fileLocking (boolean), 'writeControl' => enable / disable write control (boolean), 'readControl' => enable / disable read control (boolean), 'readControlType' => type of read control 'crc32', 'md5', 'strlen', 'memoryCaching' => enable / disable memory caching (boolean), 'onlyMemoryCaching' => enable / disable only memory caching (boolean), 'memoryCachingLimit' => max nbr of records in memory caching (int), 'fileNameProtection' => enable / disable file name protection (boolean), 'automaticSerialization' => enable / disable serialization (boolean) );
Clean the cache
if no group is specified all cache files will be destroyed else only cache files of the specified group will be destroyed
Test if a cache is available and (if yes) return it
Return the cache last modification time
BE CAREFUL : THIS METHOD IS FOR HACKING ONLY !
Trigger a PEAR error
To improve performances, the PEAR.php file is included dynamically. The file is so included only when an error is triggered. So, in most cases, the file isn't included and perfs are much better.
Remove a cache file
Save some data in a cache file
Set a new life time
Documentation generated on Sun, 04 Jun 2006 18:58:43 -0400 by phpDocumentor 1.3.0RC4