Created
May 8, 2013 04:23
-
-
Save joshuaadickerson/5538182 to your computer and use it in GitHub Desktop.
An interface to implement for caching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* An interface for caches to implement | |
*/ | |
interface iCache | |
{ | |
public function connect(); | |
public function setOptions($options); | |
public function getKey($key, $parameters); | |
/** | |
* Get a single item from the cache | |
* | |
* @param string $key What you are looking for | |
* @param array $parameters Replace parts of the key and used as arguments for the callback | |
* @param callable $callback If the request fails, call this function and return its results | |
*/ | |
public function get($key, $parameters, $callback); | |
/** | |
* Get multiple items from the cache | |
* The same as get() but allowed to use multiple keys and no callback | |
* | |
* @param array $keys An array of keys you are looking for | |
* @param array $parameters Replace parts of the key | |
* @param array $flags Flags to be used | |
*/ | |
public function getMulti($keys, $parameters, $flags); | |
/** | |
* Set a single item in the cache | |
* | |
* @param string $key The key under which to store the value | |
* @param mixed $value The value of the item | |
* @param int $ttl The amount of time the item shall live for | |
* @param array $parameters Replace parts of the key | |
*/ | |
public function set($key, $value, $ttl, $parameters); | |
/** | |
* Set multiple items | |
* | |
* @param array $array | |
* @param int $ttl | |
* @param array $parameters | |
*/ | |
public function setMulti($array, $ttl, $parameters); | |
/** | |
* Delete an item from the cache | |
* @param type $key | |
* @param type $parameters | |
*/ | |
public function delete($key, $parameters); | |
/** | |
* Delete multiple items from the cache | |
* | |
* @param array $keys | |
* @param array $parameters | |
*/ | |
public function deleteMulti($keys, $parameters); | |
/** | |
* Increase an item by its offset | |
* | |
* @throw Exception if the item is not numeric | |
* | |
* @param type $key | |
* @param type $offset | |
* @param type $initial_value | |
* @param type $ttl | |
* @param type $parameters | |
*/ | |
public function increment($key, $offset, $initial_value, $ttl, $parameters); | |
/** | |
* Lessen an item by its offset | |
* | |
* @throw Exception if the item is not numeric | |
* | |
* @param type $key | |
* @param type $offset | |
* @param type $initial_value | |
* @param type $ttl | |
* @param type $parameters | |
*/ | |
public function decrement($key, $offset, $initial_value, $ttl, $parameters); | |
/** | |
* Add an element to the end of a list | |
* | |
* @throw Exception if the item is not an array | |
* | |
* @param string $key | |
* @param mixed $value | |
* @param int $ttl | |
* @param array $parameters | |
*/ | |
public function append($key, $value, $ttl, $parameters); | |
/** | |
* Add an element to the beginning of a list | |
* | |
* @throw an Exception if the item is not an array | |
* | |
* @param string $key | |
* @param mixed $value | |
* @param int $ttl | |
* @param array $parameters | |
*/ | |
public function prepend($key, $value, $ttl, $parameters); | |
/** | |
* Get the last element of a list in the cache and remove it | |
* | |
* @throw an Exception if the item is not an array | |
* | |
* @param type $key | |
* @param type $parameters | |
*/ | |
public function pop($key, $parameters); | |
/** | |
* Get the first element of a list and remove it | |
* | |
* @throw an Exception if the item is not an array | |
* | |
* @param string $key | |
* @param array $parameters | |
*/ | |
public function shift($key, $parameters); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment