kislayphp/persistence
最新稳定版本:0.0.3
Composer 安装命令:
pie install kislayphp/persistence
包简介
Request-safe persistence runtime for KislayPHP (transaction guard + bounded cache)
关键字:
README 文档
README
v0.0.3 — Critical stability fix: removed
zval_ptr_dtorcalls fromMSHUTDOWNthat caused double-free →SIGABRTon PHP shutdown.
Per-request data persistence lifecycle for PHP microservices. Automatic transaction management when attached to a
kislayphp/coreApp — begin on request start, commit or rollback on request end.
Part of the KislayPHP ecosystem.
✨ What It Does
kislayphp/persistence provides a persistence runtime that integrates with kislayphp/core's request lifecycle hooks. Attach it to your App and every request gets automatic transaction management — begin on start, commit on success, rollback on exception.
<?php Kislay\Persistence\Runtime::attach($app); // that's it
Every request now has a clean transaction scope. No manual begin/commit/rollback per handler.
📦 Installation
pie install kislayphp/persistence
Enable in php.ini:
extension=kislayphp_persistence.so
🚀 Quick Start
Automatic Transaction Per Request
<?php $app = new Kislay\Core\App(); // Attach persistence — handles begin/commit/rollback per request automatically Kislay\Persistence\Runtime::attach($app); $app->post('/api/orders', function($req, $res) { $data = $req->getJson(); // Transaction is already open — just write your business logic $orderId = DB::create('orders', $data); Inventory::decrement($data['product_id'], $data['qty']); Email::queue('order_confirmation', $data['email']); $res->json(['order_id' => $orderId], 201); // Transaction commits automatically on clean return // Transaction rolls back automatically on exception }); $app->listen('0.0.0.0', 8080);
Manual Usage
<?php $persistence = new Kislay\Persistence\Runtime(); $persistence->begin(); try { $id = DB::insert('users', $data); Log::write('user_created', $id); $persistence->commit(); } catch (\Throwable $e) { $persistence->rollback(); throw $e; }
📖 Public API
namespace Kislay\Persistence; class Runtime { public function __construct(); public static function attach(Kislay\Core\App $app): void; // per-request auto lifecycle public function begin(): bool; public function commit(): bool; public function rollback(): bool; public function isActive(): bool; }
Legacy aliases: KislayPHP\Persistence\Runtime
🔗 Ecosystem
core · gateway · discovery · metrics · queue · eventbus · persistence
📄 License
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2026-03-02