-
Notifications
You must be signed in to change notification settings - Fork 83
/
CacheInterface.php
62 lines (57 loc) · 1.61 KB
/
CacheInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* 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.
*/
namespace Prismic\Cache;
/**
* 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 4 methods with your
* implementation, and pass an instance of your class as the $cache parameter
* in your Prismic\Api::get call.
* Two implementations are included in the PHP kit out-of-the-box:
* DefaultCache (which works with APC) and NoCache (which doesn't cache).
*
* @api
*/
interface CacheInterface
{
/**
* Returns the value of a cache entry from its key
*
* @api
*
* @param string $key the key of the cache entry
* @return \stdClass the value of the entry, as it was passed to CacheInterface::set, null if not present in cache
*/
public function get($key);
/**
* Stores a new cache entry
*
* @api
*
* @param string $key the key of the cache entry
* @param \stdClass $value the value of the entry
* @param integer $ttl the time until this cache entry expires
*/
public function set($key, $value, $ttl = 0);
/**
* Deletes a cache entry, from its key
*
* @api
*
* @param string $key the key of the cache entry
*/
public function delete($key);
/**
* Clears the whole cache
*
* @api
*/
public function clear();
}