Skip to content

Instantly share code, notes, and snippets.

@esimonetti
Created August 7, 2018 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esimonetti/4c0ce853e56a9610b1393c0dd7af22fc to your computer and use it in GitHub Desktop.
Save esimonetti/4c0ce853e56a9610b1393c0dd7af22fc to your computer and use it in GitHub Desktop.
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