spiral/roadrunner-kv

RoadRunner kv plugin bridge

v2.0.0 2021-06-17 18:21 UTC

This package is auto-updated.

Last update: 2021-07-23 14:38:11 UTC


README

Latest Stable Version Build Status Codecov

This repository contains the codebase PSR-16 PHP cache bridge using kv RoadRunner plugin.

Installation

To install application server and KV codebase

$ composer require spiral/roadrunner-kv

You can use the convenient installer to download the latest available compatible version of RoadRunner assembly:

$ composer require spiral/roadrunner-cli --dev
$ vendor/bin/rr get

Usage

First you need to add at least one kv adapter 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

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.

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'));

if (!$factory->isAvailable()) {
    throw new \LogicException('The [kv] plugin not available');
}

$cache = $factory->select('test');

// After that you can write and read arbitrary values:

$cache->set('key', 'value');

echo $cache->get('key'); // string(5) "value"

License

The MIT License (MIT). Please see LICENSE for more information. Maintained by Spiral Scout.