function reset($suffix = NULL, $lifetime = 0)
{
if (!$this->dsn) {
return TRUE;
}
$regex = '/' . preg_quote($this->prefix . '.', '/') . '.+?' . preg_quote($suffix, '/') . '/';
$parts = explode('=', $this->dsn, 2);
switch ($parts[0]) {
case 'apc':
case 'apcu':
$info = apc_cache_info('user');
if (!empty($info['cache_list'])) {
$key = array_key_exists('info', $info['cache_list'][0]) ? 'info' : 'key';
$mtkey = array_key_exists('mtime', $info['cache_list'][0]) ? 'mtime' : 'modification_time';
foreach ($info['cache_list'] as $item) {
if (preg_match($regex, $item[$key]) && $item[$mtkey] + $lifetime < time()) {
apc_delete($item[$key]);
}
}
}
return TRUE;
case 'redis':
$fw = Base::instance();
$keys = $this->ref->keys($this->prefix . '.*' . $suffix);
foreach ($keys as $key) {
$val = $fw->unserialize($this->ref->get($key));
if ($val[1] + $lifetime < time()) {
$this->ref->del($key);
}
}
return TRUE;
case 'memcache':
$fw = Base::instance();
foreach (memcache_get_extended_stats($this->ref, 'slabs') as $slabs) {
foreach (array_filter(array_keys($slabs), 'is_numeric') as $id) {
foreach (memcache_get_extended_stats($this->ref, 'cachedump', $id) as $data) {
if (is_array($data)) {
foreach (array_keys($data) as $key) {
if (preg_match($regex, $key) && ($val = $fw->unserialize(memcache_get($this->ref, $key))) && $val[1] + $lifetime < time()) {
memcache_delete($this->ref, $key);
}
}
}
}
}
}
return TRUE;
case 'wincache':
$info = wincache_ucache_info();
foreach ($info['ucache_entries'] as $item) {
if (preg_match($regex, $item['key_name']) && $item['use_time'] + $lifetime < time()) {
wincache_ucache_delete($item['key_name']);
}
}
return TRUE;
case 'xcache':
xcache_unset_by_prefix($this->prefix . '.');
return TRUE;
case 'folder':
if ($glob = @glob($parts[1] . '*')) {
foreach ($glob as $file) {
if (preg_match($regex, basename($file)) && filemtime($file) + $lifetime < time()) {
@unlink($file);
}
}
}
return TRUE;
}
return FALSE;
}