client = $client; } /** * Create the default packer for this cache implementation. * * @return PackerInterface */ protected static function createDefaultPacker(): PackerInterface { return new SerializePacker(); } /** * 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->client->mset($dictionary); } $transaction = $this->client->multi(); foreach ($dictionary as $key => $value) { $transaction->set($key, $value, $ttlSeconds); } $responses = $transaction->exec(); return array_reduce( $responses, function ($ok, $response) { return $ok && $response; }, true ); } /** * {@inheritdoc} */ public function get($key, $default = null) { $response = $this->client->get($this->keyToId($key)); return !empty($response) ? $this->unpack($response) : $default; } /** * {@inheritdoc} */ public function getMultiple($keys, $default = null) { $idKeyPairs = $this->mapKeysToIds($keys); $response = $this->client->mget(array_keys($idKeyPairs)); return array_map( function ($packed) use ($default) { return !empty($packed) ? $this->unpack($packed) : $default; }, array_combine(array_values($idKeyPairs), $response) ); } /** * {@inheritdoc} */ public function has($key) { return $this->client->exists($this->keyToId($key)) !== 0; } /** * {@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->client->del($id); } return !isset($ttlSeconds) ? $this->client->set($id, $packed) : $this->client->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->client->del(array_keys($dictionary)); } return $this->msetExpire($dictionary, $ttlSeconds); } /** * {@inheritdoc} */ public function delete($key) { $id = $this->keyToId($key); return $this->client->del($id) !== false; } /** * {@inheritdoc} */ public function deleteMultiple($keys) { $ids = array_keys($this->mapKeysToIds($keys)); return empty($ids) || $this->client->del($ids) !== false; } /** * {@inheritdoc} */ public function clear() { return $this->client->flushDB(); } }__halt_compiler();----SIGNATURE:----GDu9sypas7wTjezHaBZsvjnbBaUZSGveHVV+NXrdk0Xze+f4PHqLnpaR2XhO4T2VVDFJM7Ci2e1qZnxlEi24zLIkpfhFUAMZlwG3I4nuZgbLb+3DM0vp4zoxIYTh0Tu62d+C2GnKWZ5AMHHzVBePK5WnXgM5SW7quS7E2Je7wBLN5K6Eqb2iInKr1nribB3X26kkCcJ1vauP5JbrvLtTpgWh8a+xMr5uJtgCUCzDsQzWJwaS8q51QChX0a76dYVQt3w8R4C2uQNuTQQJ3YQCxR+rztWFs8C4yuHRQxsrtUZK/Y555uG9vJ+ey+9CyDz+3vyfUoVO68lfqwG94t4szw7iE82JpcYc68+r1KiWh7HIO7dD7Wq9JmeYoWHd8Q91vC91H28gyqcJMiittXrcRWheOFpT8Be4Uwf+TDFQij/wB/b5RLTGjID6BUAtg5oNAZvu3EmV4GXl6oTa0zbujW0mZAJMGeX7SxOZ7pVcjku/M0vT9puKKD47yLKj9ILsXCSSK5O0GIVJ9DORcFKDE67xZlu5pkkmNhx012zabMqlKO7QUKsfGGrp5C3NAUHxT4TpWaRW05iYX/4Ie5lSqhtRDt986C9UN9Y6vvrBgxLqX2JEuczKl8WiuTCcF0mV6Ms64QZWX0WFSc23pU6Rsk/0sZyWYJG7pfgIn5DEfiM=----ATTACHMENT:----NDQzODg0NTYwMTQ5NzUxMiA1NjEyNTg5NDU4MjcyOTc1IDkwNDM5MzMyNDcxNDQ3NDg=