Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677<?php
declare(strict_types=1);
namespace Wotnak\Atproto\Tests\Support;
use Psr\SimpleCache\CacheInterface;
final class IdentityTestCache implements CacheInterface {
/** * @param array<string, mixed> $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<string> $keys * @return array<string, mixed> */ public function getMultiple(iterable $keys, mixed $default = NULL): iterable { $values = []; foreach ($keys as $key) { $values[$key] = $this->get($key, $default); } return $values; }
/** * @param iterable<mixed, mixed> $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<string> $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); }
}