定制 mage-stack/module-persistent-cache 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mage-stack/module-persistent-cache

Composer 安装命令:

composer require mage-stack/module-persistent-cache

包简介

Magento 2 module for custom cache.

README 文档

README

A robust Magento 2 module that provides a persistent, isolated cache layer untouched by Magento's default CLI cache operations (cache:clean, cache:flush).

Requirements

  • Magento 2.4.8
  • PHP 8.4

Module version

  • 1.0.0

Why This Module?

In Magento 2, we often store temporary but critical data in cache — such as serialized payloads, or flags for ongoing processes. However, a major concern arises:

  • Running Magento CLI commands like bin/magento cache:flush or cache:clean can wipe out these important entries, potentially breaking business logic or corrupting workflows.

Solution: Persistent, Isolated Cache

This module creates and manages a completely isolated cache frontend using its own identifier (parsistent). Magento CLI commands do not affect it — ensuring your critical data remains safe.

Features

  • Immune to cache:clean and cache:flush
  • Supports Valkey, File, and Database backends
  • Flexible configuration via env.php
  • Simple service interface (CacheRepositoryInterface)
  • Tested with Valkey, File, and DB cache

Configuration

Add a new cache frontend in your app/etc/env.php under the cache key:

Valkey

  'cache' => [
      'frontend' => [
          'parsistent' => [
              'id_prefix' => 'YOUR_PREFIX',
              'backend' => 'Magento\\Framework\\Cache\\Backend\\Redis',
              'backend_options' => [
                  'server' => 'VALKEY_HOST',
                  'database' => 'VALKEY_DB',
                  'port' => 'VALKEY_PORT',
                  'password' => '',
                  'compress_data' => '1',
                  'compression_lib' => '',
                  'use_lua' => '0',
                  'use_lua_on_gc' => '1'
              ]
          ]
      ]
  ],

File

  'cache' => [
      'frontend' => [
          'parsistent' => [
              'id_prefix' => 'YOUR_PREFIX',
              'backend' => 'Magento\\Framework\\Cache\\Backend\\File',
              'backend_options' => [
                  'cache_dir' => BP . '/var/cache/parsistent'
              ]
          ]
      ]
  ],

DB

  'cache' => [
      'frontend' => [
          'parsistent' => [
              'id_prefix' => 'YOUR_PREFIX',
              'backend' => 'Magento\\Framework\\Cache\\Backend\\Database',
              'backend_options' => [
                  'auto_create_tables' => true
              ]
          ]
      ]
  ],

Installation

  1. Install the module via Composer: To install this module, run the following command in your Magento root directory:
    • composer require mage-stack/module-persistent-cache
  2. Enable the module: After installation, enable the module by running:
    • php bin/magento module:enable MageStack_PersistentCache
  3. Apply database updates: Run the setup upgrade command to apply any database changes:
    • php bin/magento setup:upgrade
  4. Flush the Magento cache: Finally, flush the cache:
    • php bin/magento cache:flush

Usage

Once installation is successfull, invoke MageStack\PersistentCache\Api\CacheRepositoryInterface in your class and start using available methods.

Contributing

If you would like to contribute to this module, feel free to fork the repository and create a pull request. Please make sure to follow the coding standards of Magento 2.

Reporting Issues

If you encounter any issues or need support, please create an issue on the GitHub Issues page. We will review and address your concerns as soon as possible.

License

This module is licensed under the MIT License.

Support

If you find this module useful, consider supporting me By giving this module a star on github

mage-stack/module-persistent-cache 适用场景与选型建议

mage-stack/module-persistent-cache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 4, 最近一次更新时间为 2025 年 06 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mage-stack/module-persistent-cache 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mage-stack/module-persistent-cache 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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