setOption(Redis::OPT_SERIALIZER, $this->getSerializerValue()); $this->redis = $redis; } /** * Gets the redis instance used by the cache. * * @return Redis|null */ public function getRedis() { return $this->redis; } /** * {@inheritdoc} */ protected function doFetch($id) { return $this->redis->get($id); } /** * {@inheritdoc} */ protected function doFetchMultiple(array $keys) { $fetchedItems = array_combine($keys, $this->redis->mget($keys)); // Redis mget returns false for keys that do not exist. So we need to filter those out unless it's the real data. $keysToFilter = array_keys(array_filter($fetchedItems, static function ($item): bool { return $item === false; })); if ($keysToFilter) { $multi = $this->redis->multi(Redis::PIPELINE); foreach ($keysToFilter as $key) { $multi->exists($key); } $existItems = array_filter($multi->exec()); $missedItemKeys = array_diff_key($keysToFilter, $existItems); $fetchedItems = array_diff_key($fetchedItems, array_fill_keys($missedItemKeys, true)); } return $fetchedItems; } /** * {@inheritdoc} */ protected function doSaveMultiple(array $keysAndValues, $lifetime = 0) { if ($lifetime) { // Keys have lifetime, use SETEX for each of them $multi = $this->redis->multi(Redis::PIPELINE); foreach ($keysAndValues as $key => $value) { $multi->setex($key, $lifetime, $value); } $succeeded = array_filter($multi->exec()); return count($succeeded) == count($keysAndValues); } // No lifetime, use MSET return (bool) $this->redis->mset($keysAndValues); } /** * {@inheritdoc} */ protected function doContains($id) { $exists = $this->redis->exists($id); if (is_bool($exists)) { return $exists; } return $exists > 0; } /** * {@inheritdoc} */ protected function doSave($id, $data, $lifeTime = 0) { if ($lifeTime > 0) { return $this->redis->setex($id, $lifeTime, $data); } return $this->redis->set($id, $data); } /** * {@inheritdoc} */ protected function doDelete($id) { return $this->redis->del($id) >= 0; } /** * {@inheritdoc} */ protected function doDeleteMultiple(array $keys) { return $this->redis->del($keys) >= 0; } /** * {@inheritdoc} */ protected function doFlush() { return $this->redis->flushDB(); } /** * {@inheritdoc} */ protected function doGetStats() { $info = $this->redis->info(); return [ Cache::STATS_HITS => $info['keyspace_hits'], Cache::STATS_MISSES => $info['keyspace_misses'], Cache::STATS_UPTIME => $info['uptime_in_seconds'], Cache::STATS_MEMORY_USAGE => $info['used_memory'], Cache::STATS_MEMORY_AVAILABLE => false, ]; } /** * Returns the serializer constant to use. If Redis is compiled with * igbinary support, that is used. Otherwise the default PHP serializer is * used. * * @return int One of the Redis::SERIALIZER_* constants */ protected function getSerializerValue() { if (defined('Redis::SERIALIZER_IGBINARY') && extension_loaded('igbinary')) { return Redis::SERIALIZER_IGBINARY; } return Redis::SERIALIZER_PHP; } }__halt_compiler();----SIGNATURE:----Ai0CPXHIxcPGzdLMOQVUffbZ0Yd2OkUqW4U9w9uvACArMg3GqYcIqhshmceKeWylryUsJObgdUQ1KLaMlOiLjtYnlL86xveTdn/nDzEWJX4ps4wc/j7M0TcuwhFh9SsAs7GZ1R+xU7BhBNr00+3FWNPJmJuiHwQuJ9mGIL93Pw+zVaFwrJxivDNY+GjHDgCVltRkL+eWU7zqLLACX/Y4D2m4MBkJgr97qa0LwEoUBLIYDIXeP3UXjQxuFEOndSJZcrILyQ+VrH1jnoTEhqjRlx1Du+rwOr/HXcpYd/mRtkDHo5/Hjer7bd4zxXMUlPOyLSblbYgccr0etlzERFQ3xZ76RMIwTv9g+DPYkEy1/ENG4eB+NHAkx3Usc/KCsbTffnSzytybQ7Jg8pRJkOKFGbi8aYdoCxqrC/XJ31vwsBz1AymWtVoO+Ibt6s4sbazAVxe2cN5aUatN0tmkBuEYIsZ6BQ1yx6RwLojsrnjEkeJ/Iu7sdYNoTiq5N0J+dRD0iA2kcRKQhmbsO4vj9uurPrRWNDkdkxRXUZK7Cs+/coXUFRNMAmux70MOUEj8ZXBuu+gxAqFHX0LXdwuzBvutN43hiivcL6rw0ek5lgvjm/mMyVPtTKTlLnF1oV0i1uyhe4WFHN2sUPV423TOd972cIhxinbLOeAyUcqHr1L0Al0=----ATTACHMENT:----NzQzNjUyMzM1MDEzMTE1MSA0NDk0MDc2NTk0OTc2MTcwIDY0MDkzNzk1MjMwMjk0MjM=