Interface ICache
ICache interface.
This interface must be implemented by cache managers.
| Method Summary |
|
boolean
|
Stores a value identified by a key into cache if the cache does not contain this key.
|
|
boolean
|
Deletes a value with the specified key from cache
|
|
void
|
Deletes all values from cache.
|
|
mixed
|
Retrieves a value from cache with a specified key.
|
|
boolean
|
Stores a value identified by a key into cache.
|
| Method Details |
add
| public boolean add |
(string $id , mixed $value , integer $expire , ICacheDependency $dependency ) |
Stores a value identified by a key into cache if the cache does not contain this key.
Nothing will be done if the cache already contains the key.
| Input |
| string | $id | the key identifying the value to be cached |
| mixed | $value | the value to be cached |
| integer | $expire | the number of seconds in which the cached value will expire. 0 means never expire. |
| ICacheDependency | $dependency | dependency of the cached item. If the dependency changes, the item is labelled invalid. |
| Output |
|
boolean
| true if the value is successfully stored into cache, false otherwise |
| Exception |
|
delete
| public boolean delete |
(string $id ) |
Deletes a value with the specified key from cache
| Input |
| string | $id | the key of the value to be deleted |
| Output |
|
boolean
| if no error happens during deletion |
| Exception |
|
flush
Deletes all values from cache.
Be careful of performing this operation if the cache is shared by multiple applications.
|
get
| public mixed get |
(string $id ) |
Retrieves a value from cache with a specified key.
| Input |
| string | $id | a key identifying the cached value |
| Output |
|
mixed
| the value stored in cache, false if the value is not in the cache or expired. |
| Exception |
|
set
| public boolean set |
(string $id , mixed $value , integer $expire , ICacheDependency $dependency ) |
Stores a value identified by a key into cache.
If the cache already contains such a key, the existing value and expiration time will be replaced with the new ones.
| Input |
| string | $id | the key identifying the value to be cached |
| mixed | $value | the value to be cached |
| integer | $expire | the number of seconds in which the cached value will expire. 0 means never expire. |
| ICacheDependency | $dependency | dependency of the cached item. If the dependency changes, the item is labelled invalid. |
| Output |
|
boolean
| true if the value is successfully stored into cache, false otherwise |
| Exception |
|
|