Created
August 7, 2018 04:27
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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