Documentation

CacheInterface

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\Api::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).

Table of Contents

clear()  : void
Clears the whole cache
delete()  : void
Deletes a cache entry, from its key
get()  : mixed
Returns the value of a cache entry from its key
has()  : mixed
set()  : void
Stores a new cache entry

Methods

clear()

Clears the whole cache

public clear() : void
Return values
void

delete()

Deletes a cache entry, from its key

public delete(string $key) : void
Parameters
$key : string

the key of the cache entry

Return values
void

get()

Returns the value of a cache entry from its key

public get(string $key) : mixed
Parameters
$key : string

the key of the cache entry

Return values
mixed

the value of the entry, as it was passed to CacheInterface::set, null if not present in cache

has()

public has(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

set()

Stores a new cache entry

public set(string $key, mixed $value, int $ttl) : void
Parameters
$key : string

the key of the cache entry

$value : mixed

the value of the entry

$ttl : int

the time (in seconds) until this cache entry expires

Return values
void

Search results