spiral / roadrunner-kv
PSR-16 cache on top of the RoadRunner Key-Value plugin storages (memory, boltdb, redis, memcached) over RPC
Package info
pkg:composer/spiral/roadrunner-kv
Fund package maintenance!
Requires
- php: >=8.2
- ext-json: *
- psr/simple-cache: 2 - 3
- roadrunner/api-dto: ^2.1
- roadrunner/goridge: ^4.5
- spiral/roadrunner: ^3.0
Requires (Dev)
- spiral/code-style: ^2.3.1
- testo/testo: ^0.10.55
- vimeo/psalm: ^6 || ^7
Suggests
- ext-igbinary: (>3.1.6) Igbinary serializer support
- ext-sodium: Sodium serializer support
Provides
None
Conflicts
None
Replaces
- spiral/roadrunner-kv: v4.5.0
- 4.x-dev
- v4.5.0
- v4.4.0
- v4.3.1
- v4.3.0
- v4.2.0
- v4.1.0
- 4.0.0
- 3.x-dev
- v3.0.0
- 2.x-dev
- v2.2.1
- v2.2.0
- v2.1.0
- v2.0.0
- dev-release-please--branches--4.x--components--roadrunner/kv
- dev-rr-v3
- dev-release-please--branches--4.x--components--spiral/roadrunner-kv
- dev-static-analysis
- dev-ci/mutation-testing
- dev-coverage
- dev-testo
- dev-ci/code-style
- dev-chore/codeowners
- dev-docs/readme
- dev-ci/security-audit
- dev-ci/release-please
This package is auto-updated.
Last update: 2026-10-10 13:16:23 UTC
README
PSR-16 cache on top of the RoadRunner KV plugin
This package lets a PHP application use the storages of the RoadRunner KV plugin (memory, boltdb, redis, memcached and others) as a PSR-16 cache, talking to RoadRunner over RPC.
Get Started
Installation
composer require roadrunner/kv
You can use the convenient installer to download the latest available compatible version of RoadRunner server:
composer require roadrunner/cli --dev vendor/bin/rr get
Configuration
First you need to add at least one kv plugin to your roadrunner configuration. For example, such a configuration would be quite feasible to run:
rpc: listen: tcp://127.0.0.1:6001 kv: test: driver: memory config: interval: 10
Note
Read more about all available drivers on the documentation page.
After starting the server with this configuration, one driver named "test"
will be available to you.
Usage
The following code will allow writing and reading an arbitrary value from the RoadRunner server.
<?php use Spiral\Goridge\RPC\RPC; use Spiral\RoadRunner\KeyValue\Factory; require __DIR__ . '/vendor/autoload.php'; $factory = new Factory(RPC::create('tcp://127.0.0.1:6001')); $cache = $factory->select('test'); // After that you can write and read arbitrary values: $cache->set('key', 'value'); echo $cache->get('key'); // string(5) "value"
Serialization
Values are serialized with PHP's native serialize() by default. Pass another serializer to the factory to change that:
IgbinarySerializer— requires theigbinaryextension;SodiumSerializer— encrypts values produced by an inner serializer with a keypair fromsodium_crypto_box_keypair(), requires thesodiumextension.
use Spiral\RoadRunner\KeyValue\Factory; use Spiral\RoadRunner\KeyValue\Serializer\DefaultSerializer; use Spiral\RoadRunner\KeyValue\Serializer\SodiumSerializer; $factory = new Factory($rpc, new SodiumSerializer(new DefaultSerializer(), $key));