tarantool/symfony-lock
Composer 安装命令:
composer require tarantool/symfony-lock
包简介
Symfony lock Tarantool store
关键字:
README 文档
README
About
The TarantoolStore implements symfony PersistingStoreInterface using Tarantool Database.
Installation
The recommended way to install the library is through Composer:
$ composer require tarantool/symfony-lock
Prepare Tarantool
To start working on locking you need to create schema, the package contains schema manager that can be used for that. For additional documentation on client configuration see tarantool/client repository.
use Tarantool\Client\Client; use Tarantool\SymfonyLock\SchemaManager; $client = Client::fromDefaults(); $schema = new SchemaManager($client); // create spaces and indexes $schema->setup(); // later if you want to cleanup lock space, use $schema->tearDown(); // in addition you can configure TarantoolStore to create schema on demand // pay attention, this option is false by default $store = new TarantoolStore($client, [ 'createSchema' => true, ]);
Using Store
For additional examples on lock factory usage follow symfony/lock docs
use Symfony\Component\Lock\LockFactory; use Tarantool\Client\Client; use Tarantool\SymfonyLock\TarantoolStore; $client = Client::fromDefaults(); $store = new TarantoolStore($client); $factory = new LockFactory($store); $lock = $factory->createLock('pdf-invoice-generation'); if ($lock->acquire()) { // The resource "pdf-invioce-generation" is locked. // You can compute and generate invoice safely here. $lock->release(); }
Expiration helper
When key is expired it will be removed on acquiring new lock with same name. If your key names are not unique, you can use php cleaner to cleanup your database. The best way to cleanup data is start a fiber inside tarantool. For more details see expirationd module documentation
use Tarantool\Client\Client; use Tarantool\SymfonyLock\Cleaner; $client = Client::fromDefaults(); $cleaner = new Cleaner($client); // cleanup keys that are expired $cleaner->process(); // by default cleaner will process upto 100 items // you can override it via optional configuration $cleaner = new Cleaner($client, [ 'limit' => 10, ]);
Customization
Out of the box all classes are using space named lock. If you want - you can override it via options configuration. All available options and default values are listed below:
use Tarantool\Client\Client; use Tarantool\SymfonyLock\Cleaner; use Tarantool\SymfonyLock\SchemaManager; use Tarantool\SymfonyLock\TarantoolStore; $client = Client::fromDefaults(); $cleaner = new Cleaner($client, [ 'space' => 'lock', 'limit' => '100', ]); $schema = new SchemaManager($client, [ 'engine' => 'memtx', 'space' => 'lock', ]); $store = new TarantoolStore($client, [ 'space' => 'lock', 'initialTtl' => 300, 'createSchema' => false, ]);
tarantool/symfony-lock 适用场景与选型建议
tarantool/symfony-lock 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.37k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 06 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nosql」 「client」 「lock」 「pure」 「tarantool」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tarantool/symfony-lock 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tarantool/symfony-lock 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tarantool/symfony-lock 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Redis distributed locks for laravel
The DreamFactory(tm) CouchDB Service.
Simple to use mutex implementation that can use flock, memcache, memcached, mysql or redis for locking
The CodeIgniter Redis package
PhpPlaisio: Named Lock
Mock PSR-18 HTTP client
统计信息
- 总下载量: 4.37k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 4
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-23