Apache Zeta Components - high quality PHP components

Apache Zeta Components Manual :: Docs For Class ezcCacheStorageApc

Cache::ezcCacheStorageApc

Class ezcCacheStorageApc

This class is a common base class for all APC based storage classes.

To implement an APC based cache storage, you simply have to derive from this class and implement the ezcCacheStorageApc::fetchData() and ezcCacheStorageApc::prepareData() methods.

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

The Cache package already contains these implementations of this class:

This storage acan also be used with ezcCacheStack. However, APC version 3.0.16 or newer is required for that.

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

ezcCacheStorage
   |
   --ezcCacheStorageMemory
      |
      --ezcCacheStorageApc
Version:   //autogentag//

Descendants

Child Class Description
ezcCacheStorageApcPlain This storage implementation stores data in an APC cache.
ezcCacheStorageFileApcArray This class is a replacement for the ezcCacheStorageFileArray class. Tries to serve data from a local APC cache if possible.

Constants

BACKEND_NAME = "Apc" The backend name.
REGISTRY_NAME = 'ezcCacheStorageApc_Registry' The registry name.

Inherited Member Variables

From ezcCacheStorageMemory
protected ezcCacheStorageMemory::$backend
protected ezcCacheStorageMemory::$backendName
protected ezcCacheStorageMemory::$registry
protected ezcCacheStorageMemory::$registryName
protected ezcCacheStorageMemory::$searchRegistry
From ezcCacheStorage
protected ezcCacheStorage::$properties

Method Summary

public ezcCacheStorageApc __construct( [ $location = null] , [ $options = array()] )
Creates a new cache storage in the given location.
protected abstract mixed fetchData( $identifier )
Fetches data from the cache.
protected abstract mixed prepareData( $data )
Prepares the data for storing.
public void setOptions( $options )
Return the currently set options.

Inherited Methods

From ezcCacheStorageMemory
public ezcCacheStorageMemory ezcCacheStorageMemory::__construct()
Creates a new cache storage in the given location.
protected int ezcCacheStorageMemory::calcLifetime()
Calculates the lifetime remaining for a cache object.
public int ezcCacheStorageMemory::countDataItems()
Returns the number of items in the cache matching a certain criteria.
public void ezcCacheStorageMemory::delete()
Deletes the data associated with $id or $attributes from the cache.
protected void ezcCacheStorageMemory::fetchSearchRegistry()
Fetches the search registry from the backend or creates it if empty.
protected string ezcCacheStorageMemory::generateAttrStr()
Generates a string from the $attributes array.
public string ezcCacheStorageMemory::generateIdentifier()
Generates the storage internal identifier from ID and attributes.
public int ezcCacheStorageMemory::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.
public void ezcCacheStorageMemory::lock()
Acquire a lock on the storage.
public array(string) ezcCacheStorageMemory::purge()
Purge outdated data from the storage.
protected void ezcCacheStorageMemory::registerIdentifier()
Registers an identifier to facilitate searching.
public void ezcCacheStorageMemory::reset()
Reset the complete storage.
public mixed ezcCacheStorageMemory::restore()
Restores the data from the cache.
public ezcCacheStackMetaData ezcCacheStorageMemory::restoreMetaData()
Restores and returns the meta data struct.
protected array(mixed) ezcCacheStorageMemory::search()
Searches the storage for data defined by ID and/or attributes.
public string ezcCacheStorageMemory::store()
Stores data to the cache storage under the key $id.
public void ezcCacheStorageMemory::storeMetaData()
Stores the given meta data struct.
protected void ezcCacheStorageMemory::storeSearchRegistry()
Stores the search registry in the backend.
public void ezcCacheStorageMemory::unlock()
Release a lock on the storage.
protected void ezcCacheStorageMemory::unRegisterIdentifier()
Un-registers a previously registered identifier.
protected void ezcCacheStorageMemory::validateLocation()
Checks if the location property 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 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

__construct

ezcCacheStorageApc __construct( [string $location = null] , [ $options = array()] )

Creates a new cache storage in the given location.

Options can contain the 'ttl' (Time-To-Live). This is per default set to 1 day.

For details about the options see ezcCacheStorageApcOptions.

Parameters:
Name Type Description
$location string Path to the cache location
$options array(string=>string) Options for the cache
Exceptions:
Type Description
ezcBasePropertyNotFoundException If you tried to set a non-existent option value.
Redefinition of:
Method Description
ezcCacheStorageMemory::__construct() Creates a new cache storage in the given location.
Redefined in descendants as:
Method Description
ezcCacheStorageFileApcArray::__construct() Creates a new cache storage in the given location. The location in case of this storage class must a valid file system directory. 

fetchData

mixed fetchData( string $identifier )

Fetches data from the cache.

Parameters:
Name Type Description
$identifier string The APC identifier to fetch data from
Redefined in descendants as:
Method Description
ezcCacheStorageApcPlain::fetchData() Fetches data from the cache. 
ezcCacheStorageFileApcArray::fetchData() Fetches the data from the cache. 

prepareData

mixed prepareData( mixed $data )

Prepares the data for storing.

Parameters:
Name Type Description
$data mixed Simple type or array
Exceptions:
Type Description
ezcCacheInvalidDataException If the data submitted can not be handled by this storage (object, resource).
Redefined in descendants as:
Method Description
ezcCacheStorageApcPlain::prepareData() Wraps the data in an ezcCacheStorageMemoryDataStruct structure in order to store it. 
ezcCacheStorageFileApcArray::prepareData() Wraps the data in order to be stored in APC ($useApc = true) or on the file system ($useApc = false). 

setOptions

void setOptions( ezcCacheStorageOptions $options )

Return the currently set options.

Return the currently set options. The options are returned on an array that has the same format as the one passed to ezcCacheStorage::setOptions(). The possible options for a storage depend on its implementation.

Parameters:
Name Type Description
$options ezcCacheStorageOptions
Redefinition of:
Method Description
ezcCacheStorage::setOptions() Set new options.
Documentation generated by phpDocumentor 1.4.3