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

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

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

foolz/cache

Composer 安装命令:

composer require foolz/cache

包简介

Rich girls' caching package. We want everything from dummy to permanent.

README 文档

README

Heavy duty caching package, meant for serious sites needing serious caching powers.

Requires PHP 5.4.

The gist

You must give a configuration object to an instance of cache.

<?php
Cache::instantiate(Config::forgeApc());
Cache::item('test')->set($value);
Cache::item('test')->get();
?>

And this is all if you use APC.

Storages

Currently bundled storages:

  • APC
  • Memcached
  • DB (Doctrine DBAL) (permanent storage, great for configurations)
  • Dummy (always returns not found)
  • File
  • Volatile (uses PHP Arrays and gets wiped on the end of the process)

Formats

We added several formats that might sound useless. We need the formats to be compatible with extraneous software.

Currently bundled formats:

  • ArrayJson (stores the json wrapped as array)
  • ObjectJson (stores the json wrapped as object)
  • SmartJson (uses an object to store the kind of json)
  • Plain
  • Serialized

Configuration

You can create a new configuration in two ways:

<?php
$config = Config::forgeMemcached();
// or
$config = new \Foolz\Cache\Config\Memcached;
?>

IDE hints will appear, helping you configuring the storage. You can also look in the folder classes/Foolz/Cache/Config for the configurations available.

Base configuration methods

  • $config->getStorage()

    Returns the name of the storage

  • $config->setFormat($format)

    Set one of the formats: array_json, object_json, smart_json, plain, serialized.

  • __$config->getFormat()

    Returns the name of the format

  • $config->setPrefix($prefix)

    Set a prefix for the stored items

  • $config->getPrefix()

    Get the prefix for the stored items

  • $config->setThrow($bool = false)

    Pass true if you want failed cache GETs to throw an exception. False if you prefer a fallback value. False by default.

  • $config->getThrow()

    True if GETs will throw an exception, false otherwise.

Instantiation

The Cache package features an instance system.

  • Cache::instantiate(\Foolz\Cache\Config $config, $instance_name = 'default')

    Create a new link for the caching backend.

  • Cache::destroy($instance_name)

    Destroys the link for the cache backend.

  • $item = Cache::forge($instance_name = 'default')

    Returns an instance of the link.

  • $item = Cache::item($key, $instance_name = 'default)

    Creates an instance paired with a key.

  • $item->getConfig()

    Returns the configuration object.

  • $item->getEngine()

    Returns the raw storage engine class.

  • $item->getKey()

    Returns the key for the item.

  • $item->set($value, $expiration = 0)

    Sets a value. Expiration is seconds from now.

  • $item->get()

    Returns the stored value. Returns \Foolz\Cache\Void if the value is not found. Throws \OutOfBoundsException if the Throws setting is enabled and the value is not found.

  • $item->delete()

    Delete a stored value.

  • $item->flush()

    Deletes all the entries in the engine.

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

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.76k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 19
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2012-11-10