承接 asanikovich/laravel-roadrunner-cache 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

asanikovich/laravel-roadrunner-cache

最新稳定版本:v1.0.1

Composer 安装命令:

composer require asanikovich/laravel-roadrunner-cache

包简介

RoadRunner KV cache for laravel

README 文档

README

Latest Version on Packagist GitHub Tests Status GitHub Tests Coverage Status GitHub Code Style Status GitHub Lint Status Total Downloads Licence

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

For laravel/octane 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

Installing the Package

You can install the package via composer:

composer require asanikovich/laravel-roadrunner-cache

Configuration

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 the config file and setup RPC connection:

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

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

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

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

Config file example

<?php
return [
    'default' => 'rr-memory', // Default store (optional)

    'stores' => [
        'rr-memory' => [ // Custom store name with "memory" connection 
            'driver' => 'roadrunner',
            'connection' => 'memory', // section name from KV plugin settings in RoadRunner config file (.rr.yaml)
            'serializer' => null, // Available options: null|igbinary
            'encryption_key' => null, // Available options: null|string
        ],
        'rr-boltdb' => [ // Custom store name with "boltdb" connection (another store is optional)
            'driver' => 'roadrunner',
            'connection' => 'boltdb', // section name from KV plugin settings in RoadRunner config file (.rr.yaml)
            'serializer' => null, // Available options: null|igbinary
            'encryption_key' => null, // Available options: null|string
            'prefix' => 'custom', // Custom prefix - non-empty-string
        ],
        'rr-memory-igbinary' => [ // Custom store name with "memory" connection and "igbinary" serializer
            'driver' => 'roadrunner',
            'connection' => 'memory', // section name from KV plugin settings in RoadRunner config file (.rr.yaml)
            'serializer' => 'igbinary', // Available options: null|igbinary
            'encryption_key' => null, // Available options: null|string
        ],
        'rr-memory-igbinary-encrypted' => [ // Custom store name with "memory" connection and encrypted "igbinary" serializer
            'driver' => 'roadrunner',
            'connection' => 'memory', // section name from KV plugin settings in RoadRunner config file (.rr.yaml)
            'serializer' => 'igbinary', // Available options: null|igbinary
            'encryption_key' => 'key1', // Available options: null|string
        ],
         'rr-memory-encrypted' => [ // Custom store name with "memory" connection and encrypted serializer
            'driver' => 'roadrunner',
            'connection' => 'memory', // section name from KV plugin settings in RoadRunner config file (.rr.yaml)
            'serializer' => null, // Available options: null|igbinary
            'encryption_key' => 'key2', // Available options: null|string
        ],
    ],
]

Usage

To use in your code:

<?php
    use Illuminate\Support\Facades\Cache;

    Cache::driver()->get('key'); // Default main store - rr-memory
    Cache::driver('rr-boltdb')->get('key'); // rr-boltdb store

All done! 🚀

Development

Here are some useful commands for development

Before running tests run docker-compose:

docker-compose up -d

Run tests:

composer run test

Run tests with coverage:

composer run test-coverage

Perform type checking:

composer run phpstan

Format your code:

composer run format

Updates and Changes

For details on updates and changes, please refer to our CHANGELOG.

License

Laravel RoadRunner Cache is released under The MIT License (MIT). For more information, please see our License File.

统计信息

  • 总下载量: 1.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 38
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 38
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-30