Looking to hire Laravel developers? Try LaraJobs
This package is not available.

laravel-cache-swoole-table maintained by eloquage

Description
A Laravel Cache driver using Swoole\Table for shared memory storage.
Last update
2026/11/03 08:51 (dev-main)
License
Links
Downloads
0

Comments
comments powered by Disqus

Laravel Swoole Table Cache

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.