|
Prismic.io PHP kit
3.0.0
|
Classes | |
| class | ApcCache |
| class | NoCache |
Functions | |
| has ($key) | |
| get ($key) | |
| set ($key, $value, $ttl=0) | |
| delete ($key) | |
| clear () | |
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.
| Prismic\Cache\clear | ( | ) |
Clears the whole cache
| Prismic\Cache\delete | ( | $key | ) |
Deletes a cache entry, from its key
| string | $key | the key of the cache entry |
| Prismic\Cache\get | ( | $key | ) |
Returns the value of a cache entry from its key
| string | $key | the key of the cache entry |
| 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
| Prismic\Cache\set | ( | $key, | |
| $value, | |||
$ttl = 0 |
|||
| ) |
Stores a new cache entry
| string | $key | the key of the cache entry |
| \stdClass | $value | the value of the entry |
| int | $ttl | the time (in seconds) until this cache entry expires |
1.8.12