定制 krisanalfa/bono-cache 二次开发

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

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

krisanalfa/bono-cache

Composer 安装命令:

composer require krisanalfa/bono-cache

包简介

Laravel cache manager for Bono PHP Framework

README 文档

README

#BonoCache Laravel Cache for Bono PHP Framework.

##Configuration Add these lines to your configuration file.

'bono.providers' => array(
    '\\KrisanAlfa\\Cache\\Provider\\CacheProvider'
),

'cache' => array(
    'driver' => 'file',
    'path' => __DIR__ . '/../../cache',
    'prefix' => 'bono',
)

The configuration takes three settings, they are driver, path, and prefix.

####Driver This option controls the default cache "driver" that will be used when using the Caching library. Of course, you may use other drivers any time you wish.

Supported Driver:

  • Now : file, array, apc
  • Later: norm, redis, memcached

####Path When using the file cache driver, we need an absolute location where the cache files may be stored.

##Cache Usage

Storing An Item In The Cache

$app->cache->put('key', 'value', $minutes);

Using Carbon Objects To Set Expire Time

$expiresAt = Carbon::now()->addMinutes(10);

$app->cache->put('key', 'value', $expiresAt); // cache will be expired at 10 minutes later

Storing An Item In The Cache If It Doesn't Exist

$app->cache->add('key', 'value', $minutes);

The add method will return true if the item is actually added to the cache. Otherwise, the method will return false.

Checking For Existence In Cache

if ($app->cache->has('key'))
{
    //
}

Retrieving An Item From The Cache

$value = $app->cache->get('key');

Retrieving An Item Or Returning A Default Value

$value = $app->cache->get('key', 'default');

$value = $app->cache->get('key', function() { return 'default'; });

Storing An Item In The Cache Permanently

$app->cache->forever('key', 'value');

Sometimes you may wish to retrieve an item from the cache, but also store a default value if the requested item doesn't exist. You may do this using the $app->cache->remember method:

$value = $app->cache->remember('users', $minutes, function()
{
    return Norm::factory('User')->find();
});

You may also combine the remember and forever methods:

$value = $app->cache->rememberForever('users', function()
{
    return Norm::factory('User')->find();
});

Note that all items stored in the cache are serialized, so you are free to store any type of data.

Removing An Item From The Cache

$app->cache->forget('key');

Cache Tags

Note: Cache tags are not supported when using the file cache drivers. Furthermore, when using multiple tags with caches that are stored "forever", performance will be best with a driver such as memcached, which automatically purges stale records.

Cache tags allow you to tag related items in the cache, and then flush all caches tagged with a given name. To access a tagged cache, use the tags method:

Accessing A Tagged Cache

You may store a tagged cache by passing in an ordered list of tag names as arguments, or as an ordered array of tag names.

$app->cache->tags('people', 'authors')->put('Alfa', $alfa, $minutes);

$app->cache->tags(array('people', 'artists'))->put('Ganesha', $ganesha, $minutes);

You may use any cache storage method in combination with tags, including remember, forever, and rememberForever. You may also access cached items from the tagged cache, as well as use the other cache methods such as increment and decrement:

Accessing Items In A Tagged Cache

To access a tagged cache, pass the same ordered list of tags used to save it.

$ganesha = $app->cache->tags('people', 'artists')->get('Ganesha');

$alfa = $app->cache->tags(array('people', 'authors'))->get('Alfa');

You may flush all items tagged with a name or list of names. For example, this statement would remove all caches tagged with either people, authors, or both. So, both "Ganesha" and "Alfa" would be removed from the cache:

$app->cache->tags('people', 'authors')->flush();

In contrast, this statement would remove only caches tagged with authors, so "Alfa" would be removed, but not "Ganesha".

$app->cache->tags('authors')->flush();

##Read More For more information about Laravel Cache, read this.

krisanalfa/bono-cache 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-03-11