Stack.PHP
A simple and easy to use PHP library for the Stack Exchange API.
Public Member Functions
FilestoreCache Class Reference

Provides a means to use the filesystem for caching purposes. More...

Inheritance diagram for FilestoreCache:
CacheBase

List of all members.

Public Member Functions

 __construct ($directory, $attempt_to_create=TRUE)
 Constructor for a filestore cache.
 RetrieveFromCache ($url)
 Retrieves the data for the given URL from the filestore.
 AddToCache ($url, $data, $ttl=null)
 Adds the URL and data to the filestore.
 Clear ()
 Clears all entries from the filestore.
 Cleanup ()
 Removes expired entries from the filestore.

Detailed Description

Provides a means to use the filesystem for caching purposes.

The FilestoreCache uses the filesystem to cache data from the API. This is accomplished by creating a file 'index' that keeps track of the filename=>data mapping for storing the information. This class makes use of the atomic function flock for ensuring atomic access to the index. You will not be able to guarantee consistency if this method is not available.


Constructor & Destructor Documentation

FilestoreCache::__construct ( directory,
attempt_to_create = TRUE 
)

Constructor for a filestore cache.

Parameters:
$directoryan empty directory suitable for storing cached requests
$attempt_to_createwhether to attempt to create the directory if it does not exist

Member Function Documentation

FilestoreCache::AddToCache ( url,
data,
ttl = null 
)

Adds the URL and data to the filestore.

Parameters:
$urlthe URL for the request
$datathe data for the URL
$ttlthe time-to-live (TTL) for the data

Implements CacheBase.

FilestoreCache::Clear ( )

Clears all entries from the filestore.

Note: this method also deletes the index.

Implements CacheBase.

FilestoreCache::RetrieveFromCache ( url)

Retrieves the data for the given URL from the filestore.

Parameters:
$urlthe URL to retrieve the data for
Returns:
the data for the URL or FALSE

Implements CacheBase.


The documentation for this class was generated from the following file:
 All Classes Functions Variables