~/docs
Resonate
Resonate
0.x 0.9.0, current
Laravel RESP3 Cache
Toggle sidebar
Laravel RESP3 Cache
webpatser/laravel-resp3-cache 0.9.0

Laravel RESP3 Cache 0.x

Introduction

A synchronous Redis client and Laravel cache driver backed by the ext-resp3 C parser.

webpatser/laravel-resp3-cache is a synchronous Redis client and Laravel cache driver backed by the php-resp3 C parser. Point your redis.client config at resp3 and your existing Cache::* calls parse responses through the C extension instead of pure-PHP code.

Warning: This is a 0.x release. The API may change, and breaking changes can land in any 0.x minor. Version 0.9 needs PHP 8.6 and ext-resp3 ^0.3. On PHP 8.4 or 8.5, stay on 0.8.x with ext-resp3 0.2.x.

What it provides

  • A resp3 Redis client that plugs into Laravel's RedisManager. The standard redis cache driver picks it up.
  • A resp3 cache driver (Resp3Store, a RedisStore subclass) that uses newer server commands when the server has them: single-command add(), atomic putMany(), compare-and-set, and lock release without Lua.
  • Cache tags on the resp3 store, on every topology.
  • Opt-in client-side caching through CLIENT TRACKING, with an array or APCu local store.
  • Cluster mode with slot routing, MOVED and ASK handling and optional replica reads.
  • Sentinel mode with reactive failover and optional replica reads.
  • Pub/Sub through Redis::subscribe() and Redis::psubscribe(), plus sharded pub/sub (ssubscribe()) on a cluster.
  • Server feature detection for Redis and Valkey.

Where it helps

Cache-heavy read patterns (one round trip that returns many small values) spend most of their PHP time inside the parser. The package replaces that parse step with the C implementation. The gain is largest on Cache::many(), Cache::tags()->many() and large HGETALL reads. Single-key Cache::get workloads are dominated by round-trip latency, so the parser swap matters less there. The one benchmark in the repository is on the Benchmarks page.

Requirements

Layer Versions
PHP 8.6
Laravel 11, 12, 13
ext-resp3 ^0.3 (see php-resp3)
Redis or Valkey 6.0+ (RESP3 capable); optional commands need the versions listed on the Configuration page

The package supports only the latest stable PHP release. When a new PHP version is released, the next release of this package requires it and support for the previous PHP version ends.

Limitations

  • Sentinel replica reads use random selection only.
  • Sharded pub/sub has no pattern equivalent (SPSUBSCRIBE is not in the Redis spec).
  • No connection pooling beyond STREAM_CLIENT_PERSISTENT.
  • Client-side caching works on single node and sentinel connections only; cluster connections ignore it.
  • features overrides are not supported on cluster connections.
  • On a cluster, cache:prune-stale-tags finds tags with SCAN, which reaches one node only, so tags stored on other nodes are not pruned.

License

MIT.