kislayphp/persistence
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
kislayphp/persistence 适用场景与选型建议
kislayphp/persistence 是一款 基于 C++ 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「cache」 「pdo」 「microservices」 「php-extension」 「cpp-extension」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kislayphp/persistence 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kislayphp/persistence 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kislayphp/persistence 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
repository php library
Laravel 5 - Repositories to the database layer
Rinvex Repository is a simple, intuitive, and smart implementation of Active Repository with extremely flexible & granular caching system for Laravel, used to abstract the data layer, making applications more flexible to maintain.
Laravel 5 - Repositories to the database layer
VV database abstraction layer with query builder and DB structure models
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2026-03-02