beauty-framework/tarantool-support 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

beauty-framework/tarantool-support

最新稳定版本:1.0.0

Composer 安装命令:

composer require beauty-framework/tarantool-support

包简介

Beauty Tarantool support

README 文档

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's replace, get, and delete 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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-20