kislayphp/persistence 问题修复 & 功能扩展

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

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

kislayphp/persistence

Composer 安装命令:

pie install kislayphp/persistence

包简介

Request-safe persistence runtime for KislayPHP (transaction guard + bounded cache)

README 文档

README

PHP Version License Build Status Version PIE

v0.0.3 — Critical stability fix: removed zval_ptr_dtor calls from MSHUTDOWN that caused double-free → SIGABRT on PHP shutdown.

Per-request data persistence lifecycle for PHP microservices. Automatic transaction management when attached to a kislayphp/core App — 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

Apache License 2.0 · Full Docs

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 kislayphp/persistence 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: C++

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-03-02