Class Cache_Lite

Description

Located in /libraries/pear/Cache/Lite.php (line 32)


	
			
Direct descendents
Variable Summary
Method Summary
 Cache_Lite Cache_Lite ([array $options = array(NULL)])
 boolean clean ([string $group = false])
 string get (string $id, [string $group = 'default'], [boolean $doNotTestCacheValidity = false])
 void getMemoryCachingState (mixed $id, [mixed $group = 'default'], [mixed $doNotTestCacheValidity = false])
 int lastModified ()
 void raiseError (string $msg, int $code)
 boolean remove (string $id, [string $group = 'default'])
 boolean save (string $data, [string $id = NULL], [string $group = 'default'])
 void saveMemoryCachingState (mixed $id, [mixed $group = 'default'])
 void setLifeTime (int $newLifeTime)
 void setToDebug ()
 string _hash (string $data, string $controlType)
 void _memoryCacheAdd (mixed $id, mixed $data)
 string _read ()
 void _setFileName (string $id, string $group)
 boolean _write (string $data)
 boolean _writeAndControl (string $data)
Variables
boolean $_automaticSerialization = false (line 198)

Enable / disable automatic serialization

it can be used to save directly datas which aren't strings (but it's slower)

string $_cacheDir = '/tmp/' (line 43)

Directory where to put the cache files (make sure to add a trailing slash)

boolean $_caching = true (line 52)

Enable / disable caching

(can be very usefull for the debug of cached scripts)

string $_file (line 82)

File name (with path)

boolean $_fileLocking = true (line 68)

Enable / disable fileLocking

(can avoid cache corruption under bad circumstances)

boolean $_fileNameProtection = true (line 188)

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...

string $_group (line 138)

Current cache group

string $_id (line 131)

Current cache id

int $_lifeTime = 3600 (line 59)

Cache lifetime (in seconds)

boolean $_memoryCaching = false (line 147)

Enable / Disable "Memory Caching"

NB : There is no lifetime for memory caching !

array $_memoryCachingArray = array() (line 162)

Memory caching array

int $_memoryCachingCounter = 0 (line 169)

Memory caching counter

int $_memoryCachingLimit = 1000 (line 176)

Memory caching limit

boolean $_onlyMemoryCaching = false (line 155)

Enable / Disable "Only Memory Caching" (be carefull, memory caching is "beta quality")

int $_pearErrorMode = CACHE_LITE_ERROR_RETURN (line 124)

Pear error mode (when raiseError is called)

(see PEAR doc)

boolean $_readControl = true (line 102)

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.

boolean $_readControlType = 'crc32' (line 114)

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)

int $_refreshTime (line 75)

Timestamp of the last valid cache

boolean $_writeControl = true (line 92)

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

Methods
Constructor Cache_Lite (line 225)

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' (string), 'pearErrorMode' => pear error mode (when raiseError is called) (cf PEAR doc) (int), 'memoryCaching' => enable / disable memory caching (boolean), 'onlyMemoryCaching' => enable / disable only memory caching (boolean), 'memoryCachingLimit' => max nbr of records to store into memory caching (int), 'fileNameProtection' => enable / disable automatic file name protection (boolean), 'automaticSerialization' => enable / disable automatic serialization (boolean) );

  • access: public
Cache_Lite Cache_Lite ([array $options = array(NULL)])
  • array $options: options
clean (line 361)

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

  • return: true if no problem
  • access: public
boolean clean ([string $group = false])
  • string $group: name of the cache group
get (line 246)

Test if a cache is available and (if yes) return it

  • return: data of the cache (or false if no cache available)
  • access: public
string get (string $id, [string $group = 'default'], [boolean $doNotTestCacheValidity = false])
  • string $id: cache id
  • string $group: name of the cache group
  • boolean $doNotTestCacheValidity: if set to true, the cache validity won't be tested
getMemoryCachingState (line 444)
  • access: public
void getMemoryCachingState (mixed $id, [mixed $group = 'default'], [mixed $doNotTestCacheValidity = false])
lastModified (line 462)

Return the cache last modification time

BE CAREFUL : THIS METHOD IS FOR HACKING ONLY !

  • return: last modification time
int lastModified ()
raiseError (line 477)

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.

  • access: public
void raiseError (string $msg, int $code)
  • string $msg: error message
  • int $code: error code
remove (line 332)

Remove a cache file

  • return: true if no problem
  • access: public
boolean remove (string $id, [string $group = 'default'])
  • string $id: cache id
  • string $group: name of the cache group
save (line 295)

Save some data in a cache file

  • return: true if no problem
  • access: public
boolean save (string $data, [string $id = NULL], [string $group = 'default'])
  • string $data: data to put in cache (can be another type than strings if automaticSerialization is on)
  • string $id: cache id
  • string $group: name of the cache group
saveMemoryCachingState (line 428)
  • access: public
void saveMemoryCachingState (mixed $id, [mixed $group = 'default'])
setLifeTime (line 418)

Set a new life time

  • access: public
void setLifeTime (int $newLifeTime)
  • int $newLifeTime: new life time (in seconds)
setToDebug (line 407)

Set to debug mode

When an error is found, the script will stop and the message will be displayed (in debug mode only).

  • access: public
void setToDebug ()
_hash (line 599)

Make a control key with the string containing datas

  • return: control key
  • access: private
string _hash (string $data, string $controlType)
  • string $data: data
  • string $controlType: type of control 'md5', 'crc32' or 'strlen'
_memoryCacheAdd (line 489)
  • access: private
void _memoryCacheAdd (mixed $id, mixed $data)
_read (line 522)

Read the cache file and return the content

  • return: content of the cache file
  • access: private
string _read ()
_setFileName (line 507)

Make a file name (with path)

  • access: private
void _setFileName (string $id, string $group)
  • string $id: cache id
  • string $group: name of the group
_write (line 559)

Write the given data in the cache file

  • return: true if ok
  • access: private
boolean _write (string $data)
  • string $data: data to put in cache
_writeAndControl (line 584)

Write the given data in the cache file and control it just after to avoir corrupted cache entries

  • return: true if the test is ok
  • access: private
boolean _writeAndControl (string $data)
  • string $data: data to put in cache

Documentation generated on Thu, 20 Jan 2005 17:10:12 +0000 by phpDocumentor 1.3.0RC3