You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is possible to add a cache with redis?
Something like:
<?php
/*
* This file is part of the Liquid package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @package Liquid
*/
namespace App\Helpers\Liquid\Cache;
use Liquid\Cache;
use Liquid\LiquidException;
use Illuminate\Support\Facades\Redis as RedisReader;
/**
* Implements cache stored in Redis.
*
* @codeCoverageIgnore
*/
class Redis extends Cache
{
/**
* Constructor.
*
* It checks the availability of redis.
*
* @param array $options
*
* @throws LiquidException if redis extension is not loaded or is disabled.
*/
public function __construct(array $options = array())
{
parent::__construct($options);
if (!extension_loaded('redis')) {
throw new LiquidException(get_class($this).' requires PHP redis extension or similar to be loaded.');
}
}
/**
* {@inheritdoc}
*/
public function read($key, $unserialize = true)
{
$redis = RedisReader::connection();
return $redis->get($this->prefix . $key);
}
/**
* {@inheritdoc}
*/
public function exists($key)
{
$redis = RedisReader::connection();
return $redis->exists($this->prefix . $key);
}
/**
* {@inheritdoc}
*/
public function write($key, $value, $serialize = true)
{
$redis = RedisReader::connection();
//set the key
$redis->set($this->prefix . $key, $value);
//set the expiration
//I understand this means expire in 60s.
$redis->expire($this->prefix . $key,$this->expire);
return $value;
}
/**
* {@inheritdoc}
*/
public function flush($expiredOnly = false)
{
return RedisReader::command('flushdb');
}
}
The text was updated successfully, but these errors were encountered:
You can add your own cache implementation IIRC, and, being completely clear, the cache isn't working for more anywhere more complex cases. Expect all kinds of bugs if you need to include templates with variables.
Is possible to add a cache with redis?
Something like:
The text was updated successfully, but these errors were encountered: