function set($key, $val, $ttl = 0)
{
$fw = Base::instance();
if (!$this->dsn) {
return TRUE;
}
$ndx = $this->prefix . '.' . $key;
$time = microtime(TRUE);
if ($cached = $this->exists($key)) {
list($time, $ttl) = $cached;
}
$data = $fw->serialize([$val, $time, $ttl]);
$parts = explode('=', $this->dsn, 2);
switch ($parts[0]) {
case 'apc':
case 'apcu':
return apc_store($ndx, $data, $ttl);
case 'redis':
return $this->ref->set($ndx, $data, $ttl ? ['ex' => $ttl] : []);
case 'memcache':
return memcache_set($this->ref, $ndx, $data, 0, $ttl);
case 'wincache':
return wincache_ucache_set($ndx, $data, $ttl);
case 'xcache':
return xcache_set($ndx, $data, $ttl);
case 'folder':
return $fw->write($parts[1] . $ndx, $data);
}
return FALSE;
}