Share on Facebook subscribe feed

Stateful Cache - An Extension to PHP / PEAR's Cache_Lite

 Download Stateful_Cache an extension to the Cache_Lite class that provides state and event driving caching techniques by writing a specialized State header to every cache file.

Read more about Stateful_Cache here

Stateful Cache requires the PEAR Class Cache_Lite

Download

Stateful_Cache version 0.8

 

Documentation

(Generated by PHPDocumentor)

Note - Methods and Properties in Cache_Lite have been stripped from the docs - View the Cache_Lite docs for all available parameters


 Class Stateful_Cache

Description

Extension for Cache_Lite that provides stateful caching checks for validating or invalidating cache files on variables

 

Use this class to write "state verification" functions, with values, to the header of the cache file. The function then is eval'd on the cache request and must return true for the cache file to be considered valid In order for the functions to actually work, they need to be contained within a file somewhere that is included prior to reading the cache header

 

  • author: Eric Kubischta
  • version: 2.0

Located in /scache_Lite.php (line 25)

Cache_Lite
   |
   --Stateful_Cache
Variable Summary
Method Summary
  Stateful_Cache Stateful_Cache ([ $options = array(NULL)])
  void clearState ()
  string get (string $id, [string $group = ""], [boolean $doNotTestCacheValidity = false])
  void registerState ( $function)
  bool registerStateFile (string $filePath)
  boolean save (string $data, [string $id = NULL], [string $group = ""])
Variables
 string $_statefulCacheHeader = "Stateful_Cache" (line 42)
  • var: containing the header string code that identifies that StatefulCache header Header will be in the form of (e.g.) !Stateful_Cache! functions... !Stateful_Cache_End!
 string $_stateFunctionPrePend = "SC_" (line 36)
  • var: containing the pre-pend string for all Stateful_Cache functions. This is a security measure that allows you to mask the executable name of the state function. When calling registerState, you do not include the pre-pend, it is only specified in the actual function include file
 array $_stateFunctions = array() (line 31)
  • var: of strings containing the state functions that are going to be written to the cache file. Functions are added to this array via the Stateful_Cache::registerState method
Methods
 Constructor Stateful_Cache (line 48)

Constructor for Stateful_Cache

 

Accepts same options array as Cache_Lite

 

Stateful_Cache Stateful_Cache ([ $options = array(NULL)])
  •  $options
 clearState (line 82)

Resets (clears) the state functions array

void clearState ()
 get (line 213)

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

 

This function will also check the validity of the stateful cache header if it exists

 

  • return: data of the cache (else : false)
  • access: public
string get (string $id, [string $group = ""], [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
 registerState (line 71)

Registers a state function into the _stateFunctions array that will be written to the header. This method will verify that the function is unique and hasn't already been added

void registerState $function)
  •  $function
 registerStateFile (line 61)
  • return: true on success
bool registerStateFile (string $filePath)
  • string $filePath: containing the full path to the file that is being loaded that contains the Stateful_Cache functions within the header
 save (line 281)

Save some data in a cache file If cache functions are registered, they are added to the header, after serialization, and prior to saving.

  • return: true if no problem (else : false or a PEAR_Error object)
  • access: public
boolean save (string $data, [string $id = NULL], [string $group = ""])
  • 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

Documentation generated on Wed, 05 Aug 2009 13:56:42 -0500 by phpDocumentor 1.4.0



Posted By:
Posted On: 2009-08-0
52 Views, 0 Comments

Tags: cache, stateful, lite, extension, pear, state, download, class, php, read
More Tags: PHP, caching, PHP, Technology_Internet
Region: Global

Categories: Developer > Open Source
Rate This Article
  • Currently 0/5
  • 1
  • 2
  • 3
  • 4
  • 5

0/5 (0 votes cast)



You must be signed in to comment on this Article





Total Outdoor Network
About | Contact | Advertise | Developers and Webmasters

More from TON TON Sites | Classifieds | Outdoor Business Directory