winzou/cache-bundle
最新稳定版本:1.0
Composer 安装命令:
composer require winzou/cache-bundle
包简介
This bundle provides a simple cache management to Symfony2. Now you can use a cache system without reinventing it. It supports Apc, XCache, File, ZendData and Array..
README 文档
README
Bundle is deprecated. Use https://github.com/doctrine/DoctrineCacheBundle instead.
What's that?
winzouCacheBundle provides a simple cache management. Now you can use a cache system without reinventing it. It supports Apc, XCache, File, ZendData and Array.
Installation
1. Add this bundle to your project:
Using composer
Add the following lines in your composer.json file:
"require": {
...
"winzou/cache-bundle": "dev-master"
}
Now, run composer to download the bundle:
$ composer update
2. Add this bundle to your application's kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new winzou\CacheBundle\winzouCacheBundle(), // ... ); }
Usage
In your controller:
$cache = $this->get('winzou_cache.apc');
// or
$cache = $this->get('winzou_cache.file');
// or
$cache = $this->get('winzou_cache.memcache');
// or
$cache = $this->get('winzou_cache.array');
// or
$cache = $this->get('winzou_cache.xcache');
// or
$cache = $this->get('winzou_cache.zenddata');
// or
$cache = $this->get('winzou_cache'); // in that case, it will use the default driver defined in config.yml, see below
$cache->save('bar', array('foo', 'bar'));
if ($cache->contains('bar')) {
$bar = $cache->fetch('bar');
}
$cache->delete('bar');
See Cache\AbstractCache for all the available methods.
Configuration
When using FileCache, if you don't want to store your cache files in %kernel.cache_dir%/winzou_cache (default value), then define the absolute path in your config.yml:
winzou_cache:
options:
cache_dir: %kernel.cache_dir%/MyAppCache
# or cache_dir: /tmp/MyAppCache/%kernel.environment%
If you want to define in only one place the driver you want to use, you will like the default_driver option:
winzou_cache:
options:
default_driver: apc # default is "lifetimefile"
# and then $cache = $this->get('winzou_cache')
You can now access the ApcCache with the winzou_cache service. And if you want to change the driver, you have to modify only one value in your config.yml.
If you don't define the default_driver and use $this->get('winzou_cache'), then you are using the FileCache.
Raw access
You can overwrite any option just by using the factory service. See these two very similar methods:
$factory = $this->get('winzou_cache.factory');
$cache = $factory->getCache('file', array('cache_dir' => '/tmp/cache'));
Or by defining your own service:
your_cache:
factory_service: winzou_cache.factory
factory_method: get
class: %winzou_cache.driver.abstract%
arguments:
- file # just modify this value to use another cache
- {'cache_dir': /tmp/cache } # you can omit this if you don't use FileCache or if the default value is ok for you
# and then $cache = $this->get('your_cache')
winzou/cache-bundle 适用场景与选型建议
winzou/cache-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29.07k 次下载、GitHub Stars 达 30, 最近一次更新时间为 2012 年 10 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Symfony2」 「memcache」 「cache」 「apc」 「filecache」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 winzou/cache-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 winzou/cache-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 winzou/cache-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
Simple to use mutex implementation that can use flock, memcache, memcached, mysql or redis for locking
Graphic stand-alone administration for memcached to monitor and debug purpose
Pop Cache Component for Pop PHP Framework
Laravel 5 - Repositories to the database layer
coroutine memcache pool
统计信息
- 总下载量: 29.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 30
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-10-04