mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
114 lines
2.3 KiB
PHP
114 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace Rhymix\Framework\Drivers;
|
|
|
|
/**
|
|
* The cache driver interface.
|
|
*/
|
|
interface CacheInterface
|
|
{
|
|
/**
|
|
* Create a new instance of the current cache driver, using the given settings.
|
|
*
|
|
* @param array $config
|
|
* @return void
|
|
*/
|
|
public static function getInstance(array $config);
|
|
|
|
/**
|
|
* Check if the current cache driver is supported on this server.
|
|
*
|
|
* This method returns true on success and false on failure.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public static function isSupported();
|
|
|
|
/**
|
|
* Validate cache settings.
|
|
*
|
|
* This method returns true on success and false on failure.
|
|
*
|
|
* @param mixed $config
|
|
* @return bool
|
|
*/
|
|
public static function validateSettings($config);
|
|
|
|
/**
|
|
* Get the value of a key.
|
|
*
|
|
* This method returns null if the key was not found.
|
|
*
|
|
* @param string $key
|
|
* @return mixed
|
|
*/
|
|
public function get($key);
|
|
|
|
/**
|
|
* Set the value to a key.
|
|
*
|
|
* This method returns true on success and false on failure.
|
|
* $ttl is measured in seconds. If it is zero, the key should not expire.
|
|
*
|
|
* @param string $key
|
|
* @param mixed $value
|
|
* @param int $ttl
|
|
* @param bool $force
|
|
* @return bool
|
|
*/
|
|
public function set($key, $value, $ttl = 0, $force = false);
|
|
|
|
/**
|
|
* Delete a key.
|
|
*
|
|
* This method returns true on success and false on failure.
|
|
* If the key does not exist, it should return false.
|
|
*
|
|
* @param string $key
|
|
* @return bool
|
|
*/
|
|
public function delete($key);
|
|
|
|
/**
|
|
* Check if a key exists.
|
|
*
|
|
* This method returns true on success and false on failure.
|
|
*
|
|
* @param string $key
|
|
* @return bool
|
|
*/
|
|
public function exists($key);
|
|
|
|
/**
|
|
* Increase the value of a key by $amount.
|
|
*
|
|
* If the key does not exist, this method assumes that the current value is zero.
|
|
* This method returns the new value.
|
|
*
|
|
* @param string $key
|
|
* @param int $amount
|
|
* @return int
|
|
*/
|
|
public function incr($key, $amount);
|
|
|
|
/**
|
|
* Decrease the value of a key by $amount.
|
|
*
|
|
* If the key does not exist, this method assumes that the current value is zero.
|
|
* This method returns the new value.
|
|
*
|
|
* @param string $key
|
|
* @param int $amount
|
|
* @return int
|
|
*/
|
|
public function decr($key, $amount);
|
|
|
|
/**
|
|
* Clear all keys from the cache.
|
|
*
|
|
* This method returns true on success and false on failure.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function clear();
|
|
}
|