beauty-framework / tarantool-support
Beauty Tarantool support
Requires
- php: >=8.1
- beauty-framework/cache: ^1.0
- tarantool/client: ^0.10.1
Requires (Dev)
- phpunit/phpunit: ^12.3@dev
This package is not auto-updated.
Last update: 2025-06-21 11:58:11 UTC
README
Welcome to the most "unconventional" cache driver you didn't know you wanted! 🎉
Yes, we're using Tarantool — that speedy, Lua-powered in-memory database — as a cache backend.
Because why use Redis when you can have a Tarantool? Ha-ha 😜
Installation
composer require beauty-framework/tarantool-support
Configuration
Configure your cache driver like this:
return [ 'default' => 'tarantool', 'stores' => [ 'tarantool' => [ 'driver' => 'tarantool', 'host' => '127.0.0.1', 'port' => 3301, 'user' => 'guest', 'password' => null, 'space' => 'cache', ], ], ];
And in \App\Container\Cache::configure
add Tarantool Driver:
$factory = new CacheFactory([ new RedisCacheDriver(), new KVCacheDriver(), new ArrayCacheDriver(), new FileCacheDriver(), new LruCacheDriver(), new \Beauty\Tarantool\Driver\TarantoolCacheDriver(), // <-- this ]);
Note: The DSN connection string only includes host, port, user, and password. The
space
is the logical "table" name inside Tarantool where cache items live, and it's handled internally.
How It Works
- Keys and values are stored as tuples in the Tarantool space.
- Every cache entry is a tuple
{ key, value }
. - Operations like
set
,get
,delete
map to Tarantool'sreplace
,get
, anddelete
calls respectively.
Just don’t ask about TTL — this isn’t your grandma’s Redis.
Testing
To test locally, run Tarantool with our init script:
docker run -d --name tarantool -p 3301:3301 -v $(pwd)/init.lua:/init.lua tarantool/tarantool tarantool /init.lua
init.lua
sets up the cache space with the proper format:
print("[init] Tarantool script running!") box.cfg{} box.schema.user.grant('guest', 'read,write,execute', 'universe', nil, { if_not_exists = true }) local space = box.schema.space.create('cache', { if_not_exists = true }) space:format({ { name = 'key', type = 'string' }, { name = 'value', type = 'any', is_nullable = true } }) space:create_index('primary', { parts = { 'key' }, if_not_exists = true }) print("[init] Tarantool cache space created!")
Or,
cd tests
./start-tarantool.sh
cd ../
./vendor/bin/phpunit
A Word of Caution
Using Tarantool as a cache backend is like bringing a rocket launcher to a water balloon fight — overkill, fun, and totally unexpected.
But hey, if you want blazing speed, Lua scripting, and a database that can do everything except maybe your laundry, Tarantool’s your pal.
License
MIT