/** * Sets a distributed cache. * * This stores a ms timestamp on the distributed cache (Jarves::setCache()) * and the actual data on the high-speed cache driver (Jarves::setFastCache()). * This mechanism makes sure, you gain the maximum performance by using the * fast cache driver to store the actual data and using the distributed cache driver * to store a ms timestamp where we can check (over several jarves.cms installations) * whether the cache is still valid or not. * * Use Jarves::invalidateCache($key) to invalidate this cache. * You don't have to define the full key, instead you can pass only a part of the key. * * @see invalidateCache for more information. * * Don't mix the usage of getDistributedCache() and getCache() since this method * stores extra values at the value, which makes getCache() returning something invalid. * * @param string $key * @param mixed $value Only simple data types. Serialize your value if you have objects/arrays. * @param int $lifeTime * * @return boolean * @static */ public function setDistributedCache($key, $value, $lifeTime = null) { $timestamp = microtime(true); $cache['data'] = $value; $cache['timestamp'] = $timestamp; $this->distributedCache->deleteInvalidate($key); return $this->fastCache->set($key, $cache, $lifeTime); }
public function latencies(&$response) { $lastLatency = $this->distributedCache->get('core/latency'); $result = array('frontend' => 0, 'backend' => 0, 'database' => 0, 'session' => 0, 'cache' => 0); foreach ($result as $key => &$value) { $value = isset($lastLatency[$key]) ? $lastLatency[$key] : array(); } $response['JarvesBundle/latencies'] = $result; }