*/
class DatabaseCacheDriver extends AbstractCacheDriver implements ICacheDriver
{
+ /**
+ * (@inheritdoc)
+ */
public function get($key)
{
$cache = DBA::selectFirst('cache', ['v'], ['`k` = ? AND `expires` >= ?', $key, DateTimeFormat::utcNow()]);
return null;
}
+ /**
+ * (@inheritdoc)
+ */
public function set($key, $value, $ttl = Cache::FIVE_MINUTES)
{
$fields = [
return DBA::update('cache', $fields, ['k' => $key], true);
}
+ /**
+ * (@inheritdoc)
+ */
public function delete($key)
{
return DBA::delete('cache', ['k' => $key]);
}
+ /**
+ * (@inheritdoc)
+ */
public function clear($outdated = true)
{
if ($outdated) {
*/
private $memcache;
+ /**
+ * @param string $memcache_host
+ * @param int $memcache_port
+ * @throws Exception
+ */
public function __construct($memcache_host, $memcache_port)
{
if (!class_exists('Memcache', false)) {
}
}
+ /**
+ * (@inheritdoc)
+ */
public function get($key)
{
$return = null;
return $return;
}
+ /**
+ * (@inheritdoc)
+ */
public function set($key, $value, $ttl = Cache::FIVE_MINUTES)
{
$cachekey = $this->getCacheKey($key);
}
+ /**
+ * (@inheritdoc)
+ */
public function delete($key)
{
$cachekey = $this->getCacheKey($key);
return $this->memcached->delete($cachekey);
}
+ /**
+ * (@inheritdoc)
+ */
public function clear($outdated = true)
{
if ($outdated) {
}
/**
- * @brief Sets a value if it's not already stored
- *
- * @param string $key The cache key
- * @param mixed $value The old value we know from the cache
- * @param int $ttl The cache lifespan, must be one of the Cache constants
- * @return bool
+ * (@inheritdoc)
*/
public function add($key, $value, $ttl = Cache::FIVE_MINUTES)
{
*/
private $redis;
+ /**
+ * @param string $redis_host
+ * @param int $redis_port
+ * @throws Exception
+ */
public function __construct($redis_host, $redis_port)
{
if (!class_exists('Redis', false)) {
}
}
+ /**
+ * (@inheritdoc)
+ */
public function get($key)
{
$return = null;
return $return;
}
+ /**
+ * (@inheritdoc)
+ */
public function set($key, $value, $ttl = Cache::FIVE_MINUTES)
{
$cachekey = $this->getCacheKey($key);
}
}
+ /**
+ * (@inheritdoc)
+ */
public function delete($key)
{
$cachekey = $this->getCacheKey($key);
return ($this->redis->delete($cachekey) > 0);
}
+ /**
+ * (@inheritdoc)
+ */
public function clear($outdated = true)
{
if ($outdated) {
$this->redis->unwatch();
return false;
}
+
/**
* (@inheritdoc)
*/