Path

ez components / documentation / api reference / 2007.2.1 / cache


eZ Components 2007.2.1

Cache: ezcCacheStorageFileEvalArray

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

Class: ezcCacheStorageFileEvalArray

This cache storage implementation stores arrays and scalar values (int, [source]
float, string, bool) in files on your hard disk as PHP code. In contrast to it's sibling class ezcCacheStorageFileArray, the stored PHP code is not simply required to restore the cache data, but is evaluated using PHP's eval() function. It takes its base methods from the extended storage base class ezcCacheStorageFile.
Main purpose behind these 2 similar implementations is the following: Most byte code caches are capable of caching code for included files, but not for eval()'ed strings. Therefore the ezcCacheStorageFileEvalarray class will permit you to get your cached data not cached a second time by an accellerator like APC, whereas the ezcCacheStorageFileArray class will permit you to explicitly allow this. ATTENTION: If you do not use a byte code cache with your PHP installation, the use of ezcCacheStorageFileArray is recommende over the usage of ezcCacheStorageEvalarray, since eval() is much slower than directly requiring the stored PHP code.
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
      |
      --ezcCacheStorageFileEvalArray

Inherited Member Variables

From ezcCacheStorage:
protected  ezcCacheStorage::$properties

Method Summary

protected mixed fetchData( $filename )
Fetch data from a given file name.
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.
protected array(int=>string) ezcCacheStorageFile::search()
Search the storage for data.
protected array(int=>string) ezcCacheStorageFile::searchRecursive()
Search the storage for data recursively.
public void ezcCacheStorageFile::setOptions()
Set new options.
public string ezcCacheStorageFile::store()
Store data to the cache storage.
protected void ezcCacheStorageFile::validateLocation()
Checks the path in the location property exists, and is read-/writable. It throws an exception if not.
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.
protected abstract void ezcCacheStorage::validateLocation()
Checks if the location property is valid.

Methods

fetchData

mixed fetchData( string $filename )
Fetch data from a given file name.

Parameters

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

See also:

ezcCacheStorageFile::restore().

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

Throws

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

Redefinition of

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

Last updated: Thu, 31 Jan 2008