arkonsoft/ps-file-cache 问题修复 & 功能扩展

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

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

arkonsoft/ps-file-cache

最新稳定版本:v1.0.0

Composer 安装命令:

composer require arkonsoft/ps-file-cache

包简介

Simple to file caching library

README 文档

README

A simple file cache for PHP

Installation

composer require arkonsoft/ps-file-cache

Usage

Create a new instance of the cache:

use Arkonsoft\PsModule\FileCache;
...
$cache = new FileCache(__DIR__ . '/cache/');

Store a value in the cache:

$cache->store('key', 'value');

Get a value from the cache:

$value = $cache->retrieve('key');

Retrieve method will also check whether the key is expired or not. You can turn off this feature by passing false as the second argument:

$value = $cache->retrieve('key', false);

Important

store() method uses json_encode() to serialize data. You can store any data beside "resource" type. If you'll try to do it exception will be thrown.

Additional methods

Lifetime

Base lifetime is set to 3600 seconds (1h).

You can change it in the constructor:

$cache = new FileCache('path', 6000);

Or later with:

$cache->setLifetime(6000);

IsStored

Check if a key is stored in the cache and is not empty:

$cache->isStored('key');

IsExpired

Check if a key is stored in the cache and is expired:

$cache->isExpired('key');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-13