PHPackages                             asanikovich/laravel-roadrunner-cache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. asanikovich/laravel-roadrunner-cache

ActiveLibrary[Caching](/categories/caching)

asanikovich/laravel-roadrunner-cache
====================================

RoadRunner KV cache for laravel

v1.0.1(2y ago)382.4k—0%1[3 PRs](https://github.com/asanikovich/laravel-roadrunner-cache/pulls)MITPHPPHP ^8.1

Since Jun 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/asanikovich/laravel-roadrunner-cache)[ Packagist](https://packagist.org/packages/asanikovich/laravel-roadrunner-cache)[ Docs](https://github.com/asanikovich/laravel-roadrunner-cache)[ Fund](https://ko-fi.com/asanikovich)[ RSS](/packages/asanikovich-laravel-roadrunner-cache/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (6)Versions (7)Used By (0)

Laravel RoadRunner Cache
========================

[](#laravel-roadrunner-cache)

[![Latest Version on Packagist](https://camo.githubusercontent.com/91831516334ae8da0266e6c9bff7186e25a3e9816a718b188872824abac69de4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6173616e696b6f766963682f6c61726176656c2d726f616472756e6e65722d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asanikovich/laravel-roadrunner-cache)[![GitHub Tests Status](https://camo.githubusercontent.com/e9a16999d917535d9cd073f6df0f1b5cb75c787755361cb13b7de27fb4f1d194/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6173616e696b6f766963682f6c61726176656c2d726f616472756e6e65722d63616368652f74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/asanikovich/laravel-roadrunner-cache/actions/workflows/tests.yml?query=branch%3Amaster)[![GitHub Tests Coverage Status](https://camo.githubusercontent.com/b45568afed12d304192a000a71b45aa1d404021338cdd556e8e4af7712e39c94/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6173616e696b6f766963682f6c61726176656c2d726f616472756e6e65722d63616368653f746f6b656e3d47584d4b533336443931267374796c653d666c61742d737175617265)](https://github.com/asanikovich/laravel-roadrunner-cache/actions/workflows/tests.yml?query=branch%3Amaster)[![GitHub Code Style Status](https://camo.githubusercontent.com/ed576eb78617ada3c0b40a9c80025f8b7c76d02d94a8f26765257c4b8d1edd20/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6173616e696b6f766963682f6c61726176656c2d726f616472756e6e65722d63616368652f7068707374616e2e796d6c3f6272616e63683d6d6173746572266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/asanikovich/laravel-roadrunner-cache/actions/workflows/phpstan.yml?query=branch%3Amaster)[![GitHub Lint Status](https://camo.githubusercontent.com/dd01650e80438e008affe4718a4bb78f47a9c670dea239d843bfe5770c58a91b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6173616e696b6f766963682f6c61726176656c2d726f616472756e6e65722d63616368652f70696e742e796d6c3f6272616e63683d6d6173746572266c6162656c3d6c696e74267374796c653d666c61742d737175617265)](https://github.com/asanikovich/laravel-roadrunner-cache/actions/workflows/pint.yml?query=branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/42d48f9124461e297918218b7658b93e05e2f36ecd55fda9f3222106aece6504/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6173616e696b6f766963682f6c61726176656c2d726f616472756e6e65722d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asanikovich/laravel-roadrunner-cache)[![Licence](https://camo.githubusercontent.com/dd316093e3bdd23a8aad1c26c9f0a85685a75d4e4c7e9647caac2469bc336859/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6173616e696b6f766963682f6c61726176656c2d726f616472756e6e65722d63616368652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asanikovich/laravel-roadrunner-cache)

**This Laravel package allows you to work with RoadRunner KV Cache in Laravel (as a cache driver).**

For laravel/octane users
------------------------

[](#for-laraveloctane-users)

Please note, that `swoole` in-memory or table cache works **only** inside HTTP workers.

If you want a cache that works from all parts of PHP (HTTP or CLI) - our package and RoadRunner KV will help you.

Getting Started
---------------

[](#getting-started)

### Installing the Package

[](#installing-the-package)

You can install the package via composer:

```
composer require asanikovich/laravel-roadrunner-cache
```

### Configuration

[](#configuration)

#### Configuration RoadRunner

[](#configuration-roadrunner)

Make sure you have in your RoadRunner config file (`.rr.yaml`) next sections:

- `RPC` section
- `KV` section

Full example of RoadRunner configuration file:

```
version: '3'
rpc:
  listen: 'tcp://127.0.0.1:6001'
server:
  command: php /var/www/html/vendor/bin/roadrunner-worker
http:
  address: '127.0.0.1:8080'
  pool:
    num_workers: 1
kv:
    memory:
        driver: memory
        config:
            interval: 1
    boltdb:
        driver: boltdb
        config:
            interval: 1
```

#### Publish config

[](#publish-config)

Publish the config file and setup RPC connection:

```
php artisan vendor:publish --tag="laravel-roadrunner-cache-config"
```

#### Serializers

[](#serializers)

Package supports next serializers (should be configured in `store` config):

- `null` - default php `serializer`
- `igbinary` - igbinary serializer, `ext-igbinary` is required to be installed

#### Encryption

[](#encryption)

Package supports encryption with `sodium`, requirements:

- `ext-sodium` required to be installed
- `encryption_key` filled in `store` config (generated by `sodium_crypto_box_keypair()`)

#### Setup cache config file

[](#setup-cache-config-file)

Add to cache configuration file (`/config/cache.php`) new store with driver `roadrunner`:

#### Config file example

[](#config-file-example)

```
