RoadRunner Key-Value Cache cho Laravel
Roadrunner KV Cache package cho Laravel cho phép bạn làm việc với RoadRunner Key-Value Plugin giống như một Cache driver:
use Illuminate\Support\Facades\Cache;
// Default main store - rr-memory
Cache::driver()->get('key');
// rr-boltdb store
Cache::driver('rr-boltdb')->get('key');
Plugin Key-Value cho phép lưu trữ dữ liệu tùy ý trong RoadRunner giữa các yêu cầu HTTP khác nhau hoặc các loại ứng dụng khác như CLI.
Thông qua RoadRunner, gói này hỗ trợ lưu trữ trong bộ nhớ và trình điều khiển boltdb nếu bạn cần lưu trữ bền vững. Nó cũng hỗ trợ việc mã hóa toàn diện nếu bạn có dữ liệu có thể chứa thông tin nhạy cảm, như dữ liệu người dùng cá nhân.
Tương tự như bất kỳ trình điều khiển cache nào, bạn có thể cấu hình nhiều tùy chọn với trình điều khiển Key-Value của RoadRunner. Dưới đây là một số ví dụ về tùy chọn cấu hình từ các ví dụ cấu hình cache trong tệp readme:
<?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-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
],
],
],
Bạn có thể tìm hiểu thêm về gói này, xem hướng dẫn cài đặt đầy đủ và xem mã nguồn trên GitHub.