Apache Zeta Components Manual :: Docs For Class ezcCacheStorageFileApcArray
Cache::ezcCacheStorageFileApcArray
Class ezcCacheStorageFileApcArray
This class is a replacement for the ezcCacheStorageFileArray class. Tries to serve data from a local APC cache if possible.
Options for this class are defined in ezcCacheStorageFileApcArrayOptions.
Source for this file: /Cache/src/storage/apc/apc_array.php
ezcCacheStorage | --ezcCacheStorageMemory | --ezcCacheStorageApc | --ezcCacheStorageFileApcArray
Version: | //autogentag// |
Inherited Constants
From ezcCacheStorageApc: | |
---|---|
ezcCacheStorageApc::BACKEND_NAME
|
The backend name. |
ezcCacheStorageApc::REGISTRY_NAME
|
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 ezcCacheStorageFileApcArray |
__construct(
$location
, [ $options
= array()] )
Creates a new cache storage in the given location. The location in case of this storage class must a valid file system directory. |
protected int |
calcLifetime(
$filename
, [ $useApc
= false] )
Calculates the lifetime remaining for a cache object. |
public void |
delete(
[ $id
= null] , [ $attributes
= array()] , [ $search
= false] )
Deletes the data associated with $id or $attributes from the cache. |
protected mixed |
fetchData(
$filename
, [ $useApc
= false] )
Fetches the data from the cache. |
protected mixed |
fetchObject(
$filename
)
Fetches the object from the cache. |
protected mixed |
prepareData(
$data
, [ $useApc
= false] )
Wraps the data in order to be stored in APC ($useApc = true) or on the file system ($useApc = false). |
public mixed |
restore(
$id
, [ $attributes
= array()] , [ $search
= false] )
Restores the data from the cache. |
public string |
store(
$id
, $data
, [ $attributes
= array()] )
Stores data to the cache storage. |
protected void |
validateLocation(
)
Checks the path in the location property exists, and is read-/writable. It throws an exception if not. |
Inherited Methods
From ezcCacheStorageApc | |
---|---|
public ezcCacheStorageApc |
ezcCacheStorageApc::__construct()
Creates a new cache storage in the given location. |
protected abstract mixed |
ezcCacheStorageApc::fetchData()
Fetches data from the cache. |
protected abstract mixed |
ezcCacheStorageApc::prepareData()
Prepares the data for storing. |
public void |
ezcCacheStorageApc::setOptions()
Return the currently set options. |
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
Creates a new cache storage in the given location. The location in case of this storage class must a valid file system directory.
Options can contain the 'ttl' (Time-To-Live). This is per default set to 1 day. The option 'permissions' can be used to define the file permissions of created cache items.
For details about the options see ezcCacheStorageFileApcArrayOptions.
Parameters:
Name | Type | Description |
---|---|---|
$location |
string | Path to the cache location. Must be a valid path |
$options |
array(string=>string) | Options for the cache storage |
Exceptions:
Type | Description |
---|---|
ezcBasePropertyNotFoundException |
If you tried to set a non-existent option value. |
Redefinition of:
Method | Description |
---|---|
ezcCacheStorageApc::__construct() |
Creates a new cache storage in the given location. |
calcLifetime
Calculates the lifetime remaining for a cache object.
If the TTL option is set to false, this method will always return 1 for existing items.
Parameters:
Name | Type | Description |
---|---|---|
$filename |
string | The file to calculate the remaining lifetime for |
$useApc |
bool | Use APC or not |
Redefinition of:
Method | Description |
---|---|
ezcCacheStorageMemory::calcLifetime() |
Calculates the lifetime remaining for a cache object. |
delete
Deletes the data associated with $id or $attributes from the cache.
Parameters:
Name | Type | Description |
---|---|---|
$id |
string | The item ID to purge |
$attributes |
array(string=>string) | Attributes describing the data to restore |
$search |
bool | Whether to search for items if not found directly |
Exceptions:
Type | Description |
---|---|
ezcBaseFilePermissionException |
If an already existsing cache file could not be unlinked. This exception means most likely that your cache directory has been corrupted by external influences (file permission change). |
Redefinition of:
Method | Description |
---|---|
ezcCacheStorageMemory::delete() |
Deletes the data associated with $id or $attributes from the cache. |
fetchData
Fetches the data from the cache.
Parameters:
Name | Type | Description |
---|---|---|
$filename |
string | The ID/filename from where to fetch the object |
$useApc |
bool | Use APC or the file system |
Redefinition of:
Method | Description |
---|---|
ezcCacheStorageApc::fetchData() |
Fetches data from the cache. |
fetchObject
Fetches the object from the cache.
Parameters:
Name | Type | Description |
---|---|---|
$filename |
string | The ID/filename from where to fetch the data |
prepareData
Wraps the data in order to be stored in APC ($useApc = true) or on the file system ($useApc = false).
Parameters:
Name | Type | Description |
---|---|---|
$data |
mixed | Simple type or array |
$useApc |
bool | Use APC or not |
Exceptions:
Type | Description |
---|---|
ezcCacheInvalidDataException |
If the data submitted can not be handled by this storage (object, resource). |
Redefinition of:
Method | Description |
---|---|
ezcCacheStorageApc::prepareData() |
Prepares the data for storing. |
restore
Restores the data from the cache.
Parameters:
Name | Type | Description |
---|---|---|
$id |
string | The item ID to restore |
$attributes |
array(string=>string) | Attributes describing the data to restore |
$search |
bool | Whether to search for items if not found directly |
Redefinition of:
Method | Description |
---|---|
ezcCacheStorageMemory::restore() |
Restores the data from the cache. |
store
Stores data to the cache storage.
Parameters:
Name | Type | Description |
---|---|---|
$id |
string | Unique identifier |
$data |
mixed | The data to store |
$attributes |
array(string=>string) | Attributes describing the cached data |
Exceptions:
Type | Description |
---|---|
ezcBaseFilePermissionException |
If the directory to store the cache file could not be created. This exception means most likely that your cache directory has been corrupted by external influences (file permission change). |
ezcCacheApcException |
If the data could not be stored in APC. |
ezcBaseFileIoException |
If an error occured while writing the data to the cache. If this exception occurs, a serious error occured and your storage might be corruped (e.g. broken network connection, file system broken, ...). |
ezcCacheInvalidDataException |
If the data submitted can not be handled by the implementation of ezcCacheStorageFile. Most implementations can not handle objects and resources. |
Redefinition of:
Method | Description |
---|---|
ezcCacheStorageMemory::store() |
Stores data to the cache storage under the key $id. |
validateLocation
Checks the path in the location property exists, and is read-/writable. It throws an exception if not.
Exceptions:
Type | Description |
---|---|
ezcBaseFileNotFoundException |
If the storage location does not exist. This should usually not happen, since ezcCacheManager::createCache() already performs sanity checks for the cache location. In case this exception is thrown, your cache location has been corrupted after the cache was configured. |
ezcBaseFileNotFoundException |
If the storage location is not a directory. This should usually not happen, since ezcCacheManager::createCache() already performs sanity checks for the cache location. In case this exception is thrown, your cache location has been corrupted after the cache was configured. |
ezcBaseFilePermissionException |
If the storage location is not writeable. This should usually not happen, since ezcCacheManager::createCache() already performs sanity checks for the cache location. In case this exception is thrown, your cache location has been corrupted after the cache was configured. |
Redefinition of:
Method | Description |
---|---|
ezcCacheStorageMemory::validateLocation() |
Checks if the location property is valid. |