/** * In addition to all writes being stored to $local, we'll also * keep get() values around ;). * * {@inheritdoc} */ public function getMulti(array $keys, array &$tokens = null) { $values = $this->transaction->getMulti($keys, $tokens); $missing = array_diff_key($values, $this->local->getMulti($keys)); if (!empty($missing)) { $this->local->setMulti($missing); } return $values; }
/** * {@inheritdoc} */ public function getMulti(array $keys, array &$tokens = null) { // retrieve all that we can from local cache $values = $this->local->getMulti($keys); $tokens = array(); // short-circuit reading from real cache if we have an uncommitted flush if (!$this->suspend) { // figure out which missing key we need to get from real cache $keys = array_diff($keys, array_keys($values)); foreach ($keys as $i => $key) { // don't reach out to real cache for keys that are about to be gone if ($this->local->expired($key)) { unset($keys[$i]); } } // fetch missing values from real cache if ($keys) { $missing = $this->cache->getMulti($keys); $values += $missing; } } // any tokens we get will be unreliable, so generate some replacements // (more elaborate explanation in get()) foreach ($values as $key => $value) { $token = uniqid(); $tokens[$key] = $token; $this->tokens[$token] = serialize($value); } return $values; }