$values */ public function __construct( private array $values = [], ) {} public function get(string $key, mixed $default = NULL): mixed { return \array_key_exists($key, $this->values) ? $this->values[$key] : $default; } public function set(string $key, mixed $value, int|\DateInterval|null $ttl = NULL): bool { $this->values[$key] = $value; return TRUE; } public function delete(string $key): bool { unset($this->values[$key]); return TRUE; } public function clear(): bool { $this->values = []; return TRUE; } /** * @param iterable $keys * @return array */ public function getMultiple(iterable $keys, mixed $default = NULL): iterable { $values = []; foreach ($keys as $key) { $values[$key] = $this->get($key, $default); } return $values; } /** * @param iterable $values */ public function setMultiple(iterable $values, int|\DateInterval|null $ttl = NULL): bool { foreach ($values as $key => $value) { if (!\is_string($key)) { return FALSE; } $this->set($key, $value, $ttl); } return TRUE; } /** * @param iterable $keys */ public function deleteMultiple(iterable $keys): bool { foreach ($keys as $key) { $this->delete($key); } return TRUE; } public function has(string $key): bool { return \array_key_exists($key, $this->values); } }