Path

ez components / documentation / api reference / 2007.1.1 / cache


eZ Components 2007.1.1

Cache: ezcCacheStorageFilePlain

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcCacheStorageFilePlain

This class implements a simple storage to cache plain text on the filesystem. It takes it's base methods from the extended storage base class ezcCacheStorageFile. [source]
In contrast to other ezcCacheStorageFile implementations, the stored cache data is restored using PHP's file_get_contents() class. This cache is not capable to store array values. If numeric values are stored the restored values will be of type string. The same applies to values of the simple type bool. It is highly recommended that you cast the resulting value to it's correct type, also PHP will automatically perform this cast when necessary. An explicit cast ensures, that type consistant comparisons (using the === or !== operators) will not fail on restored cache data.
An even better solution, if you want to store non-string values, are the usage of ezcCacheStorageFileArray and ezcCacheStorageFileEvalArray storage classes, since those keep the variable types of you cached data consistant.
For example code of using a cache storage, see ezcCacheManager.
The Cache package contains several other implementations of ezcCacheStorageFile. As there are:
  • ezcCacheStorageFileArray
  • ezcCacheStorageFilePlain

Parents

ezcCacheStorage
   |
   --ezcCacheStorageFile
      |
      --ezcCacheStorageFilePlain

Inherited Member Variables

From ezcCacheStorage:
protected  ezcCacheStorage::$properties

Method Summary

protected mixed fetchData( $filename )
Fetch data from the cache.
protected string prepareData( $data )
Serialize the data for storing.

Inherited Methods

From ezcCacheStorageFile :
public ezcCacheStorageFile ezcCacheStorageFile::__construct()
Creates a new cache storage in the given location.
protected int ezcCacheStorageFile::calcLifetime()
Calculates the lifetime remaining for a cache object.
public int ezcCacheStorageFile::countDataItems()
Return the number of items in the cache matching a certain criteria.
public void ezcCacheStorageFile::delete()
Delete data from the cache.
protected abstract mixed ezcCacheStorageFile::fetchData()
Fetch data from the cache.
public string ezcCacheStorageFile::generateIdentifier()
Generate the storage internal identifier from ID and attributes.
public int ezcCacheStorageFile::getRemainingLifetime()
Returns the time ( in seconds ) which remains for a cache object, before it gets outdated. In case the cache object is already outdated or does not exists, this method returns 0.
protected abstract string ezcCacheStorageFile::prepareData()
Serialize the data for storing.
public mixed|bool ezcCacheStorageFile::restore()
Restore data from the cache.
public void ezcCacheStorageFile::setOptions()
Set new options.
public string ezcCacheStorageFile::store()
Store data to the cache storage.
protected void ezcCacheStorageFile::validateLocation()
Checks if a given location is valid.
From ezcCacheStorage :
public ezcCacheStorage ezcCacheStorage::__construct()
Creates a new cache storage in the given location.
public abstract int ezcCacheStorage::countDataItems()
Return the number of items in the cache matching a certain criteria.
public abstract void ezcCacheStorage::delete()
Delete data from the cache.
public string ezcCacheStorage::getLocation()
Returns the location.
public ezcCacheStorageOptions ezcCacheStorage::getOptions()
Return the currently set options.
public abstract int ezcCacheStorage::getRemainingLifetime()
Returns the time ( in seconds ) that remains for a cache object, before it gets outdated. In case the cache object is already outdated or does not exists, this method returns 0.
public abstract mixed ezcCacheStorage::restore()
Restore data from the cache.
public void ezcCacheStorage::setOptions()
Set new options.
public abstract string ezcCacheStorage::store()
Store data to the cache storage.

Methods

fetchData

mixed fetchData( string $filename )
Fetch data from the cache.
This method does the fetching of the data itself. In this case, the method simply includes the file and returns the value returned by the include (or false on failure).

Parameters

Name Type Description
$filename string The file to fetch data from.

Redefinition of

Method Description
ezcCacheStorageFile::fetchData() Fetch data from the cache.

prepareData

string prepareData( mixed $data )
Serialize the data for storing.
Serializes a PHP variable (except type resource and object) to a executable PHP code representation string.

Parameters

Name Type Description
$data mixed Simple type or array

Throws

ClassDescription
ezcCacheInvalidDataException If the data submitted is an array,object or a resource, since this implementation of ezcCacheStorageFile can only deal with scalar values.

Redefinition of

Method Description
ezcCacheStorageFile::prepareData() Serialize the data for storing.

Last updated: Wed, 28 Nov 2007