1 | <?php |
||
9 | class MemcachedCache implements CacheInterface |
||
10 | { |
||
11 | |||
12 | protected $cache; |
||
13 | |||
14 | /** |
||
15 | * constructor |
||
16 | */ |
||
17 | public function __construct() |
||
23 | |||
24 | /** |
||
25 | * destructor closes the connection |
||
26 | */ |
||
27 | public function __destruct() |
||
33 | |||
34 | /** |
||
35 | * Connect to a server |
||
36 | * @param string $host This should be the host name or IP address you want to connect to |
||
37 | * @param int $port The port number where Memcache can be accessed |
||
38 | * @param string|boolean This should be the id of any persistent connection or set to false if it should not be persistent |
||
39 | * @return $this |
||
40 | */ |
||
41 | public function connect($host, $port, $persistent = false) |
||
46 | |||
47 | /** |
||
48 | * Add a server to connection pool |
||
49 | * @param string $host This should be the host name or IP address you want to add to the Memcache pool |
||
50 | * @param int $port The port number where Memcache can be accessed |
||
51 | * @param string|boolean This should be the id of any persistent connection or set to false if it should not be persistent |
||
52 | * @return $this |
||
53 | */ |
||
54 | public function addServer($host, $port, $persistent = false) |
||
60 | |||
61 | |||
62 | /** |
||
63 | * Adds a value to be stored on the server |
||
64 | * @param string $key This should be the key for the value you wish to add |
||
65 | * @param mixed $value The value you wish to be stored with the given key |
||
66 | * @param int $time How long should the value be stored for in seconds (0 = never expire) (max set value = 2592000 (30 Days)) |
||
67 | * @return boolean Returns true if successfully added or false on failure |
||
68 | */ |
||
69 | public function save($key, $value, $time = 0) |
||
73 | |||
74 | |||
75 | /** |
||
76 | * Replaces a stored value for a given key |
||
77 | * @param string $key This should be the key for the value you wish to replace |
||
78 | * @param mixed $value The new value that you wish to give to that key |
||
79 | * @param int $time How long should the value be stored for in seconds (0 = never expire) (max set value = 2592000 (30 Days)) |
||
80 | * @return boolean Returns true if successfully replaced or false on failure |
||
81 | */ |
||
82 | public function replace($key, $value, $time = 0) |
||
86 | |||
87 | /** |
||
88 | * Returns the values store for the given key |
||
89 | * @param string $key This should be the unique query key to get the value |
||
90 | * @return mixed The store value will be returned |
||
91 | */ |
||
92 | public function fetch($key) |
||
96 | |||
97 | /** |
||
98 | * Deletes a single value from the server based on the given key |
||
99 | * @param string $key This should be the key that you wish to delete the value for |
||
100 | * @return boolean Returns true on success or false on failure |
||
101 | */ |
||
102 | public function delete($key) |
||
106 | |||
107 | /** |
||
108 | * Deletes all values from the server |
||
109 | * @return boolean Returns true on success or false on failure |
||
110 | */ |
||
111 | public function deleteAll() |
||
115 | } |
||
116 |