Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
The aim of this customisation is to not run Redis::expire when the ttl is 0, to set no expiration for those keys
<?php
// Enrico Simonetti
// enricosimonetti.com
//
// 2018-08-07 tested on Sugar 8.0.0 on PHP 7.1
// file: custom/include/SugarCache/CustomSugarCacheRedis.php
// The aim of this customisation is to not run Redis::expire when the ttl is 0, to set no expiration for those keys
class CustomSugarCacheRedis extends SugarCacheRedis
{
// decreased priority from 920 to 919 vs SugarCacheRedis, so that the custom file is used
protected $_priority = 919;
/**
* @see SugarCacheAbstract::_setExternal()
*/
protected function _setExternal(
$key,
$value
)
{
$value = serialize($value);
$key = $this->_fixKeyName($key);
$this->_getRedisObject()->set($key,$value);
if ($this->_expireTimeout !== 0) {
$this->_getRedisObject()->expire($key, $this->_expireTimeout);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.