function load($dsn)
{
$fw = Base::instance();
if ($dsn = trim($dsn)) {
if (preg_match('/^redis=(.+)/', $dsn, $parts) && extension_loaded('redis')) {
list($host, $port, $db) = explode(':', $parts[1]) + [1 => 6379, 2 => NULL];
$this->ref = new Redis();
if (!$this->ref->connect($host, $port, 2)) {
$this->ref = NULL;
}
if (isset($db)) {
$this->ref->select($db);
}
} elseif (preg_match('/^memcache=(.+)/', $dsn, $parts) && extension_loaded('memcache')) {
foreach ($fw->split($parts[1]) as $server) {
list($host, $port) = explode(':', $server) + [1 => 11211];
if (empty($this->ref)) {
$this->ref = @memcache_connect($host, $port) ?: NULL;
} else {
memcache_add_server($this->ref, $host, $port);
}
}
}
if (empty($this->ref) && !preg_match('/^folder\\h*=/', $dsn)) {
$dsn = ($grep = preg_grep('/^(apc|wincache|xcache)/', array_map('strtolower', get_loaded_extensions()))) ? current($grep) : 'folder=' . $fw->get('TEMP') . 'cache/';
}
if (preg_match('/^folder\\h*=\\h*(.+)/', $dsn, $parts) && !is_dir($parts[1])) {
mkdir($parts[1], Base::MODE, TRUE);
}
}
$this->prefix = $fw->get('SEED');
return $this->dsn = $dsn;
}