/** * {@inheritdoc} */ public function set($key, $value, $ttl = null) { if (!$ttl) { $ttl = $this->ttl; } $this->server->set($this->getKey($key), $this->pack($value), time() + $ttl); }
/** * Create cache object * * @param $config \Centreon\Config The application configuration * @return \Desarrolla2\Cache\Cache */ public static function load($config) { $cacheType = null; if ($config->get('cache', 'enabled')) { $cacheType = $config->get('cache', 'type'); } switch ($cacheType) { case 'apc': $driver = new ApcCache(); break; case 'memcache': $driver = new MemCache(); foreach ($config->get('cache', 'servers') as $server) { list($serverHost, $serverPort) = explode(':', $server); $driver->addServer($serverHost, $serverPort); } break; case 'memcached': $driver = new Memcached(); foreach ($config->get('cache', 'servers') as $server) { list($serverHost, $serverPort) = explode(':', $server); $driver->addServer($serverHost, $serverPort); } break; case null: default: $driver = new NotCache(); break; } $ttl = $config->get('cache', 'ttl', 3600); $driver->setOption('ttl', $ttl); return new DesarrollaCache($driver); }
/** * {@inheritdoc } */ public function set($key, $value, $ttl = null) { $this->adapter->set($this->buildKey($key), $this->packData($value), $ttl ?: $this->ttl); }