Class \Scrivo\Cache\NoCache

No-cache implementation of the Cache interface.

This is an implementation of the Cache interface that you can use when you don't want any caching to take place. No data will be stored and null is returned on all fetches.

Implements
Defined in: Cache/NoCache.php.


Constructor summary

Attr. Name / Description
public

NoCache()

Create an APC cache wrapper.

Constant summary

Name Description
CACHE_SLAM Constant to indicate that a value was not stored in the cache because the entry was already taken.
DATA_STORED Constant to indicate that a value was succesfully stored in the cache.
NO_SPACE Constant to indicate that a value was not stored in the cache because there was not enough storage available.

Method summary

Attr. Type Name / Description
public

delete($key)

Pretend to delete/remove a cache entry.

public object[]

entryList()

List all (=none) entries in the cache.

public mixed

fetch($key)

Perform a failed fetch from the cache.

public int

overwrite($key, $val, $ttl)

Pretend to overwrite a variable in the cache.

public int

store($key, $val, $ttl)

Pretend to store a variable in the cache.

 


Constructor

public NoCache()

Create an APC cache wrapper.


Constants

CACHE_SLAM

Constant to indicate that a value was not stored in the cache because the entry was already taken.

Inherited from \Scrivo\Cache

Value: 2

DATA_STORED

Constant to indicate that a value was succesfully stored in the cache.

Inherited from \Scrivo\Cache

Value: 1

NO_SPACE

Constant to indicate that a value was not stored in the cache because there was not enough storage available.

Inherited from \Scrivo\Cache

Value: 3


Methods

public delete(\Scrivo\String $key)

Pretend to delete/remove a cache entry.

Parameters:

Type Name Def. Description
\Scrivo\String $key

A cache unique name for the key.

public object[] entryList()

List all (=none) entries in the cache.

This method returns an array in which the cache keys are the keys of the array entries and the data of each entry is an object of type stdClass that contains at least the following properties:

  • accessed: the access time
  • expires: the expiration time
  • created: the creation time
  • size: the size of the entry

Returns:

object[] List all (=none) entries in the cache.

public mixed fetch(\Scrivo\String $key)

Perform a failed fetch from the cache.

Parameters:

Type Name Def. Description
\Scrivo\String $key

The key for which to retrieve the value.

Returns:

mixed Perform a failed fetch from the cache.

public int overwrite(\Scrivo\String $key, mixed $val, int $ttl=3600)

Pretend to overwrite a variable in the cache.

Store any serializable variable in the cache. It is guaranteed that the data will be written. But note that it is not guaranteed that the next fetch will retrieve this value.

Parameters:

Type Name Def. Description
\Scrivo\String $key

A cache unique name for the key.

mixed $val

The (serializable) variabele to strore.

int $ttl 3600

Time to live in seconds.

Returns:

int Pretend to overwrite a variable in the cache.

Throws:

Exception Type Description
\Scrivo\SystemException When trying to store a NULL value.
public int store(\Scrivo\String $key, mixed $val, int $ttl=3600)

Pretend to store a variable in the cache.

Store any serializable variable in the cache. Note that it is not possible to overwrite an existing entry (cache slam). Such an event will not raise an error but the function will report it.

So subseqent calls to store should not made when the data to store changes between calls. If you activily want to store cache entries consider using overwrite() or first delete the entry before you store it.

Not to allow cache slams was a design decision because PHP does not allow thread save access to files. Thus when implementing a file cache disallowing a store request because an other thread is writing is considered expected behavoir.

Parameters:

Type Name Def. Description
\Scrivo\String $key

A cache unique name for the key.

mixed $val

The (serializable) variabele to strore.

int $ttl 3600

Time to live in seconds.

Returns:

int Pretend to store a variable in the cache.

Throws:

Exception Type Description
\Scrivo\SystemException When trying to store a NULL value.

Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013