modmore/revolution-cache 问题修复 & 功能扩展

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

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

modmore/revolution-cache

Composer 安装命令:

composer require modmore/revolution-cache

包简介

A PSR-6 cache implementation to access the MODX Revolution Cache Provider.

README 文档

README

A PSR-6 cache implementation to access the MODX Revolution Cache Provider.

This can be used to write custom application code against the PSR-6 caching standard, while integrating with the standard MODX 2.2+ Cache Manager. This offers access to the different cache implementations provided by MODX (file/memcached and others), and partition configuration through MODX System Settings.

RevolutionCache was developed for Commerce, but extracted into a standalone composer package to benefit others.

Installation

Install RevolutionCache via Composer:

composer require modmore/revolution-cache

License

MIT

Usage

You can read more about the PSR-6 Caching Interface Standard here.

A simple example of how you might use this adapter is as follows.

require_once '/path/to/vendor/autoload.php';

$pool = new \modmore\RevolutionCache\Pool($modx);

// Do some cache stuff
$item = $pool->getItem('my_value');
if ($item->isHit()) {
    echo 'Your number is ' . $item->get() . ' and was loaded from cache.';
}
else {
    $value = mt_rand(1, 9999);
    $item->set($value);
    if ($pool->save($item)) {
        echo 'Your number is ' . $value . ' and has been stored in the cache.';
    }
    else {
        echo 'Your number is ' . $value . ' but could not be written to cache';
    }
}

To use a partition other than default, you can specify it as the second option when creating the $pool instance:

$pool = new \modmore\RevolutionCache\Pool($modx, 'my_custom_partition');

The third $options property on the constructor can be used to specify xPDOCache options like the default expiry date, cache handler, and cache format, however it's recommended to configure this via MODX System Settings instead.

Notes

  • This caching implementation does not support deferred saving: $pool->saveDeferred() is identical to $pool->save() and $pool->commit() is always true.
  • This implementation does not support extensions to PSR-6 from the PHP-Cache project like tagging, namespaces or hierarchy.
  • This implementation does support something similar to namespaces from the PHP-Cache project, by supporting what in MODX are called Cache Partitions or Cache Providers. When creating the Pool instance, you provide the partition name as the second parameter. Different partitions may have their own defaults for expiration time, caching driver, and the format in which they are stored. These are typically configured in the MODX System Settings, but may also be passed in the third $options property of the constructor.
  • The modCacheManager supports cache key with directories (e.g. users/10/messages), however / is a reserved character with PSR-6, so you can not use those with this caching implementation. Instead you can use different partitions.

Tests

This implementation follows the PSR-6 spec as tested with the PSR-6 integration tests provided by the PHP-Cache project.

To run these tests, or to contribute to RevolutionCache:

  1. Install MODX
  2. Create a config.core.php file in the root of this project, pointing to the MODX core folder. There's an example in config.core.sample.php
  3. Make sure dependencies are installed with composer install
  4. Run phpunit from the project root.

modmore/revolution-cache 适用场景与选型建议

modmore/revolution-cache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.86k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 08 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 modmore/revolution-cache 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 4.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-30