Cache: ezcCacheStorageMemory
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcCacheStorageMemory
|
Base abstract class for all memory storage classes. [
source]
Abstract classes extending this class:
Implementations derived from this class and its descendants:
Parents
ezcCacheStorage
|
--ezcCacheStorageMemory
Descendents
| Child Class |
Description |
| ezcCacheStorageMemcache |
This class is a common base class for all Memcache based storage classes.
|
| ezcCacheStorageApc |
This class is a common base class for all APC based storage classes.
|
Member Variables
|
protected ezcCacheMemoryBackend |
$backend
Holds the memory backend object which communicates with the memory handler (Memcache, APC). |
|
protected string |
$backendName
Holds the name of the memory backend. |
|
protected array(mixed) |
$registry
= array()
Holds the registry. |
|
protected string |
$registryName
Holds the name of the registry. |
|
protected array(mixed) |
$searchRegistry
= array()
Holds the search registry. |
Inherited Member Variables
From
ezcCacheStorage:
Method Summary
|
public ezcCacheStorageMemory |
__construct(
$location, [$options = array()] )
Creates a new cache storage in the given location. |
|
protected int |
calcLifetime(
$identifier, [$dataObject = false] )
Calculates the lifetime remaining for a cache object. |
|
public int |
countDataItems(
[$id = null], [$attributes = array()] )
Returns the number of items in the cache matching a certain criteria. |
|
public void |
delete(
[$id = null], [$attributes = array()], [$search = false] )
Deletes the data associated with $id or $attributes from the cache. |
|
protected void |
fetchSearchRegistry(
[$requireFresh = false] )
Fetches the search registry from the backend or creates it if empty. |
|
protected string |
generateAttrStr(
[$attributes = array()] )
Generates a string from the $attributes array. |
|
public string |
generateIdentifier(
$id, [$attributes = null] )
Generates the storage internal identifier from ID and attributes. |
|
public int |
getRemainingLifetime(
$id, [$attributes = array()] )
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 void |
registerIdentifier(
[$id = null], [$attributes = array()], [$identifier = null] )
Registers an identifier to facilitate searching. |
|
public mixed |
restore(
$id, [$attributes = array()], [$search = false] )
Restores the data from the cache. |
|
protected array(mixed) |
search(
[$id = null], [$attributes = array()] )
Searches the storage for data defined by ID and/or attributes. |
|
public string |
store(
$id, $data, [$attributes = array()] )
Stores data to the cache storage under the key $id. |
|
protected void |
storeSearchRegistry(
)
Stores the search registry in the backend. |
|
protected void |
unRegisterIdentifier(
[$id = null], [$attributes = array()], [$identifier = null], [$delayStore = false] )
Un-registers a previously registered identifier. |
|
protected void |
validateLocation(
)
Checks if the location property is valid. |
Inherited Methods
From
ezcCacheStorage :
Methods
__construct
ezcCacheStorageMemory __construct(
string
$location, [
$options = array()] )
Creates a new cache storage in the given location.
Options can contain the 'ttl' (Time-To-Live). Specific implementations can have additional options.
Parameters
| Name |
Type |
Description |
$location |
string |
Path to the cache location. Null for memory-based storage and an existing writeable path for file or memory/file storage. |
$options |
array(string=>string) |
Options for the cache |
Throws
| Class | Description |
ezcBasePropertyNotFoundException |
If you tried to set a non-existent option value. The accepted options depend on the ezcCacheStorage implementation and may vary. |
Redefinition of
Redefined in descendants as
calcLifetime
int calcLifetime(
string
$identifier, [bool
$dataObject = false] )
Calculates the lifetime remaining for a cache object.
Parameters
| Name |
Type |
Description |
$identifier |
string |
The memcache identifier |
$dataObject |
bool |
The optional data object for which to calculate the lifetime |
Redefined in descendants as
countDataItems
int countDataItems(
[string
$id = null], [array(string=>string)
$attributes = array()] )
Returns the number of items in the cache matching a certain criteria.
This method determines if cache data described by the given ID and/or attributes exists. It returns the number of cache data items found.
Parameters
| Name |
Type |
Description |
$id |
string |
The item ID |
$attributes |
array(string=>string) |
Attributes describing the data |
Redefinition of
delete
void delete(
[string
$id = null], [array(string=>string)
$attributes = array()], [bool
$search = false] )
Deletes the data associated with $id or $attributes from the cache.
Additional attributes provided will matched additionally. This can give you an immense speed improvement against just searching for ID (see
ezcCacheStorage::restore()).
If you only provide attributes for deletion of cache data, all cache data matching these attributes will be purged.
Parameters
| Name |
Type |
Description |
$id |
string |
The item ID to purge |
$attributes |
array(string=>string) |
Attributes describing the data to restore |
$search |
bool |
Wheather to search for items if not found directly |
Throws
| Class | 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
Redefined in descendants as
fetchSearchRegistry
void fetchSearchRegistry(
[bool
$requireFresh = false] )
Fetches the search registry from the backend or creates it if empty.
Parameters
| Name |
Type |
Description |
$requireFresh |
bool |
To create a new search registry or not |
generateAttrStr
string generateAttrStr(
[array(string=>string)
$attributes = array()] )
Generates a string from the $attributes array.
Parameters
| Name |
Type |
Description |
$attributes |
array(string=>string) |
Attributes describing the data |
generateIdentifier
string generateIdentifier(
string
$id, [array(string=>string)
$attributes = null] )
Generates the storage internal identifier from ID and attributes.
Parameters
| Name |
Type |
Description |
$id |
string |
The ID |
$attributes |
array(string=>string) |
Attributes describing the data |
getRemainingLifetime
int getRemainingLifetime(
string
$id, [array(string=>string)
$attributes = array()] )
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.
Parameters
| Name |
Type |
Description |
$id |
string |
The item ID |
$attributes |
array(string=>string) |
Attributes describing the data |
Redefinition of
| Method |
Description |
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. |
registerIdentifier
void registerIdentifier(
[string
$id = null], [array
$attributes = array()], [string
$identifier = null] )
Registers an identifier to facilitate searching.
Parameters
| Name |
Type |
Description |
$id |
string |
ID for the cache item |
$attributes |
array |
Attributes for the cache item |
$identifier |
string |
Identifier generated for the cache item |
restore
mixed restore(
string
$id, [array(string=>string)
$attributes = array()], [bool
$search = false] )
Restores the data from the cache.
During access to cached data the caches are automatically expired. This means, that the ezcCacheStorageMemory object checks before returning the data if it's still actual. If the cache has expired, data will be deleted and false is returned.
You should always provide the attributes you assigned, although the cache storages must be able to find a cache ID even without them. BEWARE: Finding cache data only by ID can be much slower than finding it by ID and attributes.
Parameters
| Name |
Type |
Description |
$id |
string |
The item ID to restore |
$attributes |
array(string=>string) |
Attributes describing the data to restore |
$search |
bool |
Wheather to search for items if not found directly |
Redefinition of
Redefined in descendants as
search
array(mixed) search(
[string
$id = null], [array(string=>string)
$attributes = array()] )
Searches the storage for data defined by ID and/or attributes.
Parameters
| Name |
Type |
Description |
$id |
string |
The item ID |
$attributes |
array(string=>string) |
Attributes describing the data |
store
string store(
string
$id, mixed
$data, [array(string=>string)
$attributes = array()] )
Stores data to the cache storage under the key $id.
The type of cache data which is expected by an ezcCacheStorageMemory implementation depends on the backend. In most cases strings and arrays will be accepted, in some rare cases only strings might be accepted.
Using attributes you can describe your cache data further. This allows you to deal with multiple cache data at once later. Some ezcCacheStorageMemory implementations also use the attributes for storage purposes. Attributes form some kind of "extended ID".
Parameters
| Name |
Type |
Description |
$id |
string |
Unique identifier for the data |
$data |
mixed |
The data to store |
$attributes |
array(string=>string) |
Attributes describing the cached data |
Redefinition of
Redefined in descendants as
storeSearchRegistry
void storeSearchRegistry(
)
Stores the search registry in the backend.
unRegisterIdentifier
void unRegisterIdentifier(
[string
$id = null], [array
$attributes = array()], [string
$identifier = null], [bool
$delayStore = false] )
Un-registers a previously registered identifier.
Parameters
| Name |
Type |
Description |
$id |
string |
ID for the cache item |
$attributes |
array |
Attributes for the cache item |
$identifier |
string |
Identifier generated for the cache item |
$delayStore |
bool |
Delays the storing of the updated search registry |
validateLocation
void validateLocation(
)
Checks if the location property is valid.
Redefinition of
Redefined in descendants as
Last updated: Mon, 17 Dec 2007