Search by

eloquage / laravel-cache-swoole-table

zagambila

A Laravel Cache driver using Swoole\Table for shared memory storage.

Package info

github.com/eloquage/laravel-cache-swoole-table

Language:Blade

pkg:composer/eloquage/laravel-cache-swoole-table

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.1 2026-11-03 07:51 UTC

This package is auto-updated.

Last update: 2026-11-03 08:15:43 UTC


README

Laravel Swoole Table Cache package banner

A Laravel cache driver backed by Swoole\Table. It is intended for persistent Swoole or Octane workers that need a fast, process-shared in-memory cache.

Requires PHP 8.3+ (8.3, 8.4, or 8.5), Laravel 11, 12, or 13, and the Swoole PHP extension.

Install

composer require eloquage/laravel-cache-swoole-table

Add a store to config/cache.php:

'stores' => [
    'swoole-table' => [
        'driver' => 'swoole-table',
        'table_size' => 1024, // Maximum number of cache entries
        'value_size' => 65536, // Maximum serialized value size in bytes
    ],
],

Use it like another Laravel cache store:

use Illuminate\Support\Facades\Cache;

$cache = Cache::store('swoole-table');
$cache->put('visits', 1, 60);
$cache->increment('visits');

$count = $cache->get('visits'); // 2

You can make it the default store with CACHE_STORE=swoole-table.

Notes

  • Entries live in memory and are lost when the Swoole table is recreated. This is not a persistent or cross-host cache.
  • table_size sets the row capacity. Choose enough rows for the number of keys the application will store.
  • value_size must fit the serialized value. Swoole\Table::set() can fail when the table is full or a value exceeds its configured column width.
  • TTL expiration is checked when a key is read.

Tests

composer install
composer test

The test environment must have the Swoole extension enabled.

License

MIT. See LICENSE.md.