moust/silex-cache
Composer 安装命令:
composer require moust/silex-cache
包简介
Cache service provider for Silex application
README 文档
README
Silex Cache Service Provider
The Silex Cache service provider allows you to use several PHP opcode cache in your Silex application.
Installation
To enable it, add this dependency to your composer.json file:
{
"require": {
"moust/silex-cache": "~2.0"
}
}
Parameters
- cache.options: Array of cache options.
- driver: The cache driver to use. Can be any of:
apc,apcu,array,file,memcache,memcached,xcache,redis,wincache. - cache_dir: Only relevant for
filecache driver, specifies the path to the cache directory - memcache: Only relevant for
memcachecache driver, provide the Memcache instance to use. If not defined, a default Memcache object will be instanciated. See the Memcache documentation for additional informations : PHP: Memcache - Manual - memcached: Only relevant for
memcachedcache driver, provide the Memcached instance to use. If not defined, a default Memcached object will be instanciated. See the Memcached documentation for additional informations : PHP: Memcached - Manual - redis: Only relevant for
rediscache driver, provide the Redis instance to use. If not defined, a default Redis object will be instanciated. See the PhpRedis documentation for additional informations : PhpRedis
- driver: The cache driver to use. Can be any of:
Registering
$app->register(new Moust\Silex\Provider\CacheServiceProvider(), array( 'cache.options' => array( 'driver' => 'apc' ) ));
Usage
The Cache provider provides a cache service. Here is a usage example:
// stores a variable $app['cache']->store('foo', 'bar'); // stores a variable with a 1 minute lifetime $app['cache']->store('foo', 'bar', 60); // fetch variable echo $app['cache']->fetch('foo'); // delete variable $app['cache']->delete('foo'); // clear all cached variables $app['cache']->clear();
Using multiple caches
The Cache provider can allow access to multiple caches. In order to configure the cache drivers, replace the cache.options with caches.options. caches.options is an array of configurations where keys are cache names and values are options:
$app->register(new Moust\Silex\Provider\CacheServiceProvider(), array( 'caches.options' => array( 'apc' => array( 'driver' => 'apc' ), 'filesystem' => array( 'driver' => 'file', 'cache_dir' => './temp' ), 'memory' => array( 'driver' => 'array' ), 'memcache' => array( 'driver' => 'memcache', 'memcache' => function () { $memcache = new \Memcache; $memcache->connect('localhost', 11211); return $memcache; } ) ) ));
The first registered cache is the default and can simply be accessed as you would if there was only one. Given the above configuration, these two lines are equivalent:
$app['cache']->store('foo', 'bar'); $app['caches']['apc']->store('foo', 'bar');
Licence
Copyright (c) 2014 Quentin Aupetit
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
moust/silex-cache 适用场景与选型建议
moust/silex-cache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 140.9k 次下载、GitHub Stars 达 33, 最近一次更新时间为 2014 年 01 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「silex」 「cache」 「library」 「service」 「provider」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 moust/silex-cache 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 moust/silex-cache 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 moust/silex-cache 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Object-oriented CRUD for Doctrine DBAL
Laravel 5 - Repositories to the database layer
Command bus implementation: Commands and domain events
Inbox pattern process implementation for your Laravel Applications
Pomm service provider for the Silex µframwork.
统计信息
- 总下载量: 140.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 33
- 点击次数: 6
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-01-16