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

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

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

phoole/cache

Composer 安装命令:

composer require phoole/cache

包简介

Slim and full compatible PSR-16 cache library for PHP

README 文档

README

Build Status Scrutinizer Code Quality Code Climate PHP 7 Latest Stable Version License

Slim and full compatible PSR-16 cache library for PHP

Installation

Install via the composer utility.

composer require "phoole/cache"

or add the following lines to your composer.json

{
    "require": {
       "phoole/cache": "1.1.*"
    }
}

Features

  • Fully PSR-16 compliant.

  • Support all serializable PHP data types.

  • Extra features:

    • Stampede Protection: Whenever ONE cached object's lifetime is less than a configurable stampedeGap time in seconds (60s default), by a configurable stampedePercent (5% default) percentage, it will be considered stale. It may then trigger generating new cache depend on your decision. This feature is quite useful for reducing a single hot item stampede situation.

      // overwrite stampede defaults
      $cache = new Cache($fileAdatpor, [
          'stampedeGap' => 120,   // 120second
          'stampedePercent' => 2  // 2%
      ]);
    • Distributed expiration: By setting distributedPercent (5% default) to a reasonable percentage, system will store each cache item with its TTL(time to live) a small random fluctuation. This will help avoiding large amount of items expired at the same time.

      $cache = new Cache($fileAdaptor, [
          'distributedPercent' => 3,   // 3%, default is 5%
      ]);
  • CacheAwareInterface and CacheAwareTrait

Usage

  • Simple usage

    use Phoole\Cache\Cache;
    
    // using default adaptor and default settings
    $cache = new Cache();
    
    // get with default value 'phoole'
    $name  = $cache->get('name', 'phoole');
      
    // set cache
    $cache->set('name', 'wow');
  • Specify the adaptor

    use Phoole\Cache\Cache;
    use Phoole\Cache\Adaptor\FileAdaptor;
    
    // use file adaptor and specific cache directory 
    $cache = new Cache(new FileAdaptor('/tmp/cache');
  • Use with dependency injection

    use Phoole\Cache\Cache;
    use Phoole\Di\Container;
    use Phoole\Config\Config;
    
    // config cache in the container
    $container = new Container(new Config(
        'di.service' => [
            'cache' => Cache::class
        ],
    ));
    
    // get from container
    $cache = $container->get('cache');
    
    // or static FACADE way
    $cache = Container::cache();

Testing

$ composer test

Dependencies

License

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2019-10-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固