Custom Cache Implementations
Config::$cache accepts any PSR-16 Psr\SimpleCache\CacheInterface. The SDK itself has no direct dependency on any specific cache backend — you bring the implementation.
php
use BioTime\Config;
use Psr\SimpleCache\CacheInterface;
class ArrayCache implements CacheInterface
{
private array $store = [];
public function get(string $key, mixed $default = null): mixed
{
return $this->store[$key] ?? $default;
}
public function set(string $key, mixed $value, \DateInterval|int|null $ttl = null): bool
{
$this->store[$key] = $value;
return true;
}
public function delete(string $key): bool
{
unset($this->store[$key]);
return true;
}
// ...implement the remaining CacheInterface methods (clear, getMultiple, setMultiple, deleteMultiple, has)
}
$config = Config::fromArray([
'ip' => '192.168.1.50',
'username' => 'admin',
'password' => 'secret',
'cache' => new ArrayCache(),
]);Any real-world PSR-16 package works the same way — Symfony's PSR-16 cache adapter, a Redis- or Memcached-backed implementation, or Laravel's cache store (already wired up for you automatically — see Laravel installation).
Only the auth token is cached this way — see Caching for what's stored, under what key, and for how long.