Prismic.io PHP kit  3.0.0
Classes | Functions
Prismic\Cache Namespace Reference

Classes

class  ApcCache
 
class  NoCache
 

Functions

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

Detailed Description

This file is part of the Prismic PHP SDK

Copyright 2013 Zengularity (http://www.zengularity.com).

For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

Function Documentation

§ clear()

Prismic\Cache\clear ( )

Clears the whole cache

Returns
void

§ delete()

Prismic\Cache\delete (   $key)

Deletes a cache entry, from its key

Parameters
string$keythe key of the cache entry
Returns
void

§ get()

Prismic\Cache\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

§ has()

Prismic\Cache\has (   $key)

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 Prismicget 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).

@param string $key the key of the cache entry
@return boolean true if the cache has a value for this key, otherwise false

§ set()

Prismic\Cache\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