Prismic.io PHP kit  3.0.0
Public Member Functions | List of all members
Prismic\Cache\CacheInterface Interface Reference
Inheritance diagram for Prismic\Cache\CacheInterface:
Prismic\Cache\ApcCache Prismic\Cache\NoCache

Public Member Functions

 has ($key)
 
 get ($key)
 
 set ($key, $value, $ttl=0)
 
 delete ($key)
 
 clear ()
 

Detailed Description

This is the interface you're supposed to implement if you want to use your own caching strategy with the kit.

The way it works is pretty simple: implement the methods with your implementation, and pass an instance of your class as the $cache parameter in your Prismic::get call.

When writing your implementation be sure to check if your cache backend has a maximum key length. If so you will need to perform an operation on the key passed to the interface methods to limit the length, such as hashing it, since there is no guarantee that the passed keys will be any particular length.

Two implementations are included in the PHP kit out-of-the-box: ApcCache (which works with APC) and NoCache (which doesn't cache).

Member Function Documentation

§ clear()

Prismic\Cache\CacheInterface::clear ( )

Clears the whole cache

Returns
void

Implemented in Prismic\Cache\ApcCache, and Prismic\Cache\NoCache.

§ delete()

Prismic\Cache\CacheInterface::delete (   $key)

Deletes a cache entry, from its key

Parameters
string$keythe key of the cache entry
Returns
void

Implemented in Prismic\Cache\ApcCache, and Prismic\Cache\NoCache.

§ get()

Prismic\Cache\CacheInterface::get (   $key)

Returns the value of a cache entry from its key

Parameters
string$keythe key of the cache entry
Returns
mixed the value of the entry, as it was passed to CacheInterface::set, null if not present in cache

Implemented in Prismic\Cache\NoCache, and Prismic\Cache\ApcCache.

§ has()

Prismic\Cache\CacheInterface::has (   $key)

Tests whether the cache has a value for a particular key

Parameters
string$keythe key of the cache entry
Returns
boolean true if the cache has a value for this key, otherwise false

Implemented in Prismic\Cache\NoCache, and Prismic\Cache\ApcCache.

§ set()

Prismic\Cache\CacheInterface::set (   $key,
  $value,
  $ttl = 0 
)

Stores a new cache entry

Parameters
string$keythe key of the cache entry
\stdClass$valuethe value of the entry
int$ttlthe time (in seconds) until this cache entry expires
Returns
void

Implemented in Prismic\Cache\ApcCache, and Prismic\Cache\NoCache.


The documentation for this interface was generated from the following file: