Welcome Guest, Not a member yet? Register   Sign In
Never Expire Memcache
#1

[eluser]Unknown[/eluser]
Hi All,

I'm using CI memcached as below:-

Code:
$CI =& get_instance();
$result = array();

$c_key = 'country/US';
$c_res = $CI->cache->memcached->get($c_key);

if ($c_res !== FALSE) {
    $result = $c_res;
} else {
    $result = 'Hello World';
    $CI->cache->memcached->save($c_key, $result, 300);   // 5 minutes
}


The "result" is able to cache, and the script is able to retrieve memcache data.
But the problem is it never expire after 5 minutes!


I manage to solve this by updating core file system/libraries/Cache/drivers/Cache_memcached.php :-

Code:
public function save($id, $data, $ttl = 60)
{
    return $this->_memcached->add($id, array($data, time(), $ttl), 0, $ttl);
}

* change 3rd parameter to "0", in stead of $ttl

It is an update on core file, am I doing the right thing?




Theme © iAndrew 2016 - Forum software by © MyBB