predis = $client; } /** * Create the default packer for this cache implementation. * * @return PackerInterface */ protected static function createDefaultPacker(): PackerInterface { return new SerializePacker(); } /** * Run a predis command. * * @param string $cmd * @param mixed ...$args * @return mixed|bool */ protected function execCommand(string $cmd, ...$args) { $command = $this->predis->createCommand($cmd, $args); $response = $this->predis->executeCommand($command); if ($response instanceof ErrorInterface) { return false; } if ($response instanceof Status) { return $response->getPayload() === 'OK'; } return $response; } /** * Set multiple (mset) with expire * * @param array $dictionary * @param int|null $ttlSeconds * @return bool */ protected function msetExpire(array $dictionary, ?int $ttlSeconds): bool { if (empty($dictionary)) { return true; } if (!isset($ttlSeconds)) { return $this->execCommand('MSET', $dictionary); } $transaction = $this->predis->transaction(); foreach ($dictionary as $key => $value) { $transaction->set($key, $value, 'EX', $ttlSeconds); } try { $responses = $transaction->execute(); } catch (ServerException $e) { return false; } $ok = array_reduce($responses, function($ok, $response) { return $ok && $response instanceof Status && $response->getPayload() === 'OK'; }, true); return $ok; } /** * {@inheritdoc} */ public function get($key, $default = null) { $id = $this->keyToId($key); $response = $this->execCommand('GET', $id); return !empty($response) ? $this->unpack($response) : $default; } /** * {@inheritdoc} */ public function getMultiple($keys, $default = null) { $idKeyPairs = $this->mapKeysToIds($keys); $ids = array_keys($idKeyPairs); $response = $this->execCommand('MGET', $ids); if ($response === false) { return false; } $items = []; $packedItems = array_combine(array_values($idKeyPairs), $response); foreach ($packedItems as $key => $packed) { $items[$key] = isset($packed) ? $this->unpack($packed) : $default; } return $items; } /** * {@inheritdoc} */ public function has($key) { return $this->execCommand('EXISTS', $this->keyToId($key)); } /** * {@inheritdoc} */ public function set($key, $value, $ttl = null) { $id = $this->keyToId($key); $packed = $this->pack($value); if (!is_string($packed)) { throw new UnexpectedValueException("Packer must create a string for the data"); } $ttlSeconds = $this->ttlToSeconds($ttl); if (isset($ttlSeconds) && $ttlSeconds <= 0) { return $this->execCommand('DEL', [$id]); } return !isset($ttlSeconds) ? $this->execCommand('SET', $id, $packed) : $this->execCommand('SETEX', $id, $ttlSeconds, $packed); } /** * {@inheritdoc} */ public function setMultiple($values, $ttl = null) { $this->assertIterable($values, 'values not iterable'); $dictionary = []; foreach ($values as $key => $value) { $id = $this->keyToId(is_int($key) ? (string)$key : $key); $packed = $this->pack($value); if (!is_string($packed)) { throw new UnexpectedValueException("Packer must create a string for the data"); } $dictionary[$id] = $packed; } $ttlSeconds = $this->ttlToSeconds($ttl); if (isset($ttlSeconds) && $ttlSeconds <= 0) { return $this->execCommand('DEL', array_keys($dictionary)); } return $this->msetExpire($dictionary, $ttlSeconds); } /** * {@inheritdoc} */ public function delete($key) { $id = $this->keyToId($key); return $this->execCommand('DEL', [$id]) !== false; } /** * {@inheritdoc} */ public function deleteMultiple($keys) { $ids = array_keys($this->mapKeysToIds($keys)); return empty($ids) || $this->execCommand('DEL', $ids) !== false; } /** * {@inheritdoc} */ public function clear() { return $this->execCommand('FLUSHDB'); } }__halt_compiler();----SIGNATURE:----J01sfm2aCm6GzExWbRgTVXGZSxxn4vy5iu0Im1C02wtoIRKreTamwgMb2itRwbzXPrvZ2PJX5SMO5+bJYyvCzf3Q4u+nUo4XPSaXdYbTzyU2La2X9ty5k8f6erVuBWqTaUYFYzlepxnV7dQNgNC4EvZeEOeX8vj4Xg6ZiG5b+Oh3VF1bQn8yGlDUZ7jvqglt+zC+MPTBj53YviahxmpkW5CSlEVjb3S2WGHujB408g+whpGCRAG6sTt6F2xmwhloSZJqB2FgvNeu6tlFoYS1kKW+Zoquh7/jfWl95gCMHaHfcKkZna53Whr7gDzCKOaLdPppQBfpbE5POG09nzVrPcHH5jKGhfb5VtN+z8/fzeqeQpVBkagBt/+q0KFr0+RKpk+hAWULLr+w3U4g7Upe4ZbLvtr9dbl0so1DI3zxwhuiS2W5wb9ibPmeEuzQ80zCXrkE4Q2orFb+yz1BfDJeRmqSAeEH1pAYouvEPp3oMC5gXk7z2N5m7JGuvrnLLGYjog4aZ0SGh+4v75TsBVNQdGAhxmTEFTvDrVl+tEWzCoamZoSEWQsO/qhCtm96R5Nf+fY+Uk0xQQep78lFqgvW530IG5qgvG5W6+HP3TsXXmze37j8CuDSP5xMB7vslK2pPRZppKKyKoqPN9HYaYEPklJFKXNpdQm+vHT9upH5LNc=----ATTACHMENT:----ODY1NTk2ODkyNDc3Nzk0MCA1NjEzNzgzODI1NzYzODgzIDg0NDAwNzk2MDQzNjUyNzk=