Valkey Adapter (valkey)#
Factory:
Cache::valkey(string $namespace = 'default', string $dsn = 'valkey://127.0.0.1:6379', ?Redis $client = null)
Requirements:
ext-redis(phpredis client)reachable Valkey server
Highlights:
Redis-protocol compatible adapter for Valkey deployments
namespace-prefixed keys
MGETbatch retrievalfactory auto-configures
RedisLockProviderforremember()lock ownership uses random tokens with atomic Redis-compatible lease renewal and release
DSN notes:
host/port parsed from DSN
optional password and DB selection (
/db-index) are supported
Example#
use Infocyph\CacheLayer\Cache\Cache;
$cache = Cache::valkey('api', 'valkey://127.0.0.1:6379/0');
$payload = $cache->remember(
'endpoint.v1.users.page.1',
fn () => fetchApiPayload(),
ttl: 30,
tags: ['users'],
);