-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStoreInterface.php
More file actions
77 lines (70 loc) · 2.04 KB
/
StoreInterface.php
File metadata and controls
77 lines (70 loc) · 2.04 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* Interface that MUST be implemented by supported Cache Stores.
*
* @package SugiPHP.Cache
* @author Plamen Popov <tzappa@gmail.com>
* @license http://opensource.org/licenses/mit-license.php (MIT License)
*/
namespace SugiPHP\Cache;
/**
* Cache Store Interface
*/
interface StoreInterface
{
/**
* Stores an item in the cache for a specified period of time only if it is not already stored.
* StoreInterface::add() is similar to StoreInterface::set(), but the operation fails if the key
* already exists.
*
* @param string $key
* @param mixed $value The value to be stored.
* @param integer $ttl Time to live in seconds. 0 means to store it for a maximum time possible
*
* @return boolean TRUE if the value is set, FALSE on failure
*/
public function add($key, $value, $ttl = 0);
/**
* Stores an item in the cache for a specified period of time.
* StoreInterface::set() is similar to StoreInterface::add(), but the operation will not fail if
* the key already exist.
*
* @param string $key
* @param mixed $value The value to be stored.
* @param integer $ttl Time to live in seconds. 0 means to store it for a maximum time possible
*
* @return boolean TRUE if the value is set, FALSE if storing failed
*/
public function set($key, $value, $ttl = 0);
/**
* Retrieve an item from the cache.
*
* @param string $key
*
* @return mixed The value that was stored, or NULL if the value was not set or expired or not
* available for some other reason
*/
public function get($key);
/**
* Determine if an item exists in the cache.
*
* @param string $key
*
* @return boolean
*/
public function has($key);
/**
* Removes an item from the cache.
*
* @param string $key
*
* @return void
*/
public function delete($key);
/**
* Removes all items from the cache.
*
* @return void
*/
public function flush();
}