Apache Zeta Components - high quality PHP components

Apache Zeta Components Manual :: Docs For Class ezcCacheStorageFileObject

Cache::ezcCacheStorageFileObject

Class ezcCacheStorageFileObject

This cache storage implementation stores arrays, scalar values

(int, float, string, bool) and objects implementing ezcBaseExportable in files on your hard disk as PHP code. This makes the restoring of cache data extremly fast, since the stored data is simply included and parsed by the PHP interpreter. It takes its base methods from the extended storage base class ezcCacheStorageFile.

This cache storage deprecates ezcCacheStorageFileArray, since it is also capable of storing exportable objects in addition to arrays and scalar values.

For example code of using a cache storage, see ezcCacheManager.

The Cache package contains several other implementations of ezcCacheStorageFile. As there are:

  • ezcCacheStorageFileEvalArray
  • ezcCacheStorageFilePlain
Both of these use different methods for actually storing the data, which are basically not superior to the implementation in this class.

Source for this file: /Cache/src/storage/file/object.php

ezcCacheStorage
   |
   --ezcCacheStorageFile
      |
      --ezcCacheStorageFileObject
Version:   //autogentag//

Inherited Member Variables

From ezcCacheStorageFile
protected ezcCacheStorageFile::$lockResource
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 exist, this method returns 0.
public void ezcCacheStorageFile::lock()
Acquire a lock on the storage.
protected abstract string ezcCacheStorageFile::prepareData()
Serialize the data for storing.
public array(string) ezcCacheStorageFile::purge()
Purges the given number of cache items.
public void ezcCacheStorageFile::reset()
Resets the whole storage.
public mixed|bool ezcCacheStorageFile::restore()
Restore data from the cache.
public ezcCacheStackMetaData|null ezcCacheStorageFile::restoreMetaData()
Restores and returns the meta data struct.
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.
public void ezcCacheStorageFile::storeMetaData()
Stores the given meta data struct.
protected void ezcCacheStorageFile::storeRawData()
Actually stores the given data.
public void ezcCacheStorageFile::unlock()
Release a lock on the 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 exist, 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 the cache.

This method fetches the desired data from the file with $filename from disk. This implementation uses an include statement for fetching. The return value depends on the stored data and might either be an object implementing ezcBaseExportable, an array or a scalar value.

Parameters:
Name Type Description
$filename string
Redefinition of:
Method Description
ezcCacheStorageFile::fetchData() Fetch data from the cache.

prepareData

string prepareData( mixed $data )

Serialize the data for storing.

Serializes the given $data to a executable PHP code representation string. This works with objects implementing ezcBaseExportable, arrays and scalar values (int, bool, float, string). The return value is executable PHP code to be stored to disk. The data can be unserialized using the fetchData() method.

Parameters:
Name Type Description
$data mixed
Exceptions:
Type Description
ezcCacheInvalidDataException if the $data can not be serialized (e.g. an object that does not implement ezcBaseExportable, a resource, ...).
Redefinition of:
Method Description
ezcCacheStorageFile::prepareData() Serialize the data for storing.
Documentation generated by phpDocumentor 1.4.3