soflomo/cache 问题修复 & 功能扩展

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

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

soflomo/cache

Composer 安装命令:

composer require soflomo/cache

包简介

Command line utility for cache management in Zend Framework 2

README 文档

README

Soflomo\Cache is a command line utility for cache management in Zend Framework 2. It enables you to manage your Zend\Cache instances from the commandline, including:

  1. Printing a list of all available cache services
  2. Get the status (total space, available space) of all services
  3. Flush the complete cache instance
  4. Clear the cache by expired items
  5. Clear the cache by namespace
  6. Clear the cache by prefix
  7. Removing ZF2 application caches: the merged config and module map files

Installation

Soflomo\Cache works with Composer. Make sure you have the composer.phar downloaded and you have a composer.json file at the root of your project. To install it, add the following line into your composer.json file:

"require": {
    "soflomo/cache": "~0.2"
}

After installation of the package, you need to enable the module by adding Soflomo\Cache to your application.config.php file.

Requirements

  1. Zend Framework 2: the Zend\Cache component
  2. Zend Framework 2: the Zend\Mvc component

Configuration

Soflomo\Cache scans automatically the list of available caches from the caches key in the configuration. This key serves to define your caches as service. If you want to use this key, you must register the cache as abstract factory:

'service_manager' => array(
    'abstract_factories' => array(
        'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
    ),
),

With Soflomo\Cache you are not forced to use the cache abstract factory. The only prerequisite is the cache must be available as a service. You can register your own cache service using e.g. the service manager. For these self-defined caches you cannot use the --list and --status --all commands and you are required to supply the service name of the cache.

Usage

Typing php public/index.php will show you a list of all available commands in your application, including all Soflomo\Cache commands.

List all available caches

php public/index.php cache --list

NB. You have to define your caches using the abstract factory.

Get the cache status

php public/index.php cache --status

If you have only one cache defined, this cache is picked. For more than one cache, you will get to choose which cache's status must be printed.

When your cache is defined without using the abstract factory, you must supply the cache name:

php public/index.php cache --status MyCacheServiceName

All cache statuses are listed with --all:

php public/index.php cache --status --all

Note with the --all only caches from the abstract factory are listed.

Flush the cache

php public/index.php cache --flush

If you have only one cache defined, this cache is picked. For more than one cache, you will get to choose which cache's status must be printed.

When your cache is defined without using the abstract factory, you must supply the cache name:

php public/index.php cache --flush MyCacheServiceName

All clearing operations, including --flush will require confirmation via the prompt. Using the command non-interactively, you can use the --force or -f flag:

php public/index.php cache --flush --force

Clear all expired items

php public/index.php cache --clear --expired

If you have only one cache defined, this cache is picked. For more than one cache, you will get to choose which cache's status must be printed.

When your cache is defined without using the abstract factory, you must supply the cache name:

php public/index.php cache --clear MyCacheServiceName --expired

All clearing operations, including --clear --expired will require confirmation via the prompt. Using the command non-interactively, you can use the --force or -f flag:

php public/index.php cache --clear --expired --force

Clear items by namespace

php public/index.php cache --clear --by-namespace=MyNamespace

If you have only one cache defined, this cache is picked. For more than one cache, you will get to choose which cache's status must be printed.

When your cache is defined without using the abstract factory, you must supply the cache name:

php public/index.php cache --clear MyCacheServiceName --by-namespace=MyNamespace

All clearing operations, including --clear --by-namespace=MyNamespace will require confirmation via the prompt. Using the command non-interactively, you can use the --force or -f flag:

php public/index.php cache --clear --force --by-namespace=MyNamespace

Clear items by prefix

php public/index.php cache --clear --by-prefix=MyPrefix

If you have only one cache defined, this cache is picked. For more than one cache, you will get to choose which cache's status must be printed.

When your cache is defined without using the abstract factory, you must supply the cache name:

php public/index.php cache --clear MyCacheServiceName --by-prefix=MyPrefix

All clearing operations, including --clear --by-prefix=MyPrefix will require confirmation via the prompt. Using the command non-interactively, you can use the --force or -f flag:

php public/index.php cache --clear --force --by-prefix=MyPrefix

Clear the ZF2 application's config cache

php public/index.php cache --clear-config

Clear the ZF2 application's module map

php public/index.php cache --module-map

Clearing opcode cache

At this moment, it is not possible to clear the opcode cache. The opcode caches of CLI and PHP-FPM are not shared and as such, you cannot control the cache from PHP-FPM with the CLI.

Like the Symfony ApcBundle it is required to create a file in the web directory and call that file via HTTP. Then the file itself can clear the PHP-FPM opcode cache. You can track the progress of this feature in the issue #2.

soflomo/cache 适用场景与选型建议

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

它主要适用于以下技术方向: 「cache」 「cli」 「zf2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 10.94k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 3
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-05-08