定制 adinan-cenci/file-cache 二次开发

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

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

adinan-cenci/file-cache

最新稳定版本:2.0.1

Composer 安装命令:

composer require adinan-cenci/file-cache

包简介

A PSR-16 implementation around the PHP Filesystem.

README 文档

README

This is a PSR-16 implementation build around the php Filesystem.

How to use it

Once instantiated, use like specified in the PSR-16

use AdinanCenci\FileCache\Cache;
$cache = new Cache('my-cache-directory/');

Caching

Inform an unique identifier for the data you desire to cache. Optionally you may inform its time to live, otherwise the cached data will never expire.

$cache->set('somethingCostlyToAcquire', $value, 60 * 60 * 24);

Caching multiple values at once

$cache->setMultiple([
    'foo'           => $bar,
    'hello'         => $world,
    'myObject'      => $myObject
], 60 * 60 * 24);

Retrieving

Use ::get to retrieve your data, if the data doesn't exist in cache or has expired then a fallback value will be returned, which defaults to null if not informed.

$fallback = 'nothing here';
$cache->get('somethingCostlyToAcquire', $fallback);

Retrieving multiple values at once

$cache->getMultiple([
    'object1', 
    'value1',
    'anotherObject'
], $fallback);

How to install

Use composer

composer require adinan-cenci/file-cache

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-18