定制 xnicon/simple-php-cache 二次开发

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

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

xnicon/simple-php-cache

Composer 安装命令:

composer require xnicon/simple-php-cache

包简介

Simple PHP cache

README 文档

README

Quick Start

To install Simple PHP Cache, simply:

$ composer require xnicon/php-simple-cache

Code Examples

Example One

require __DIR__ . '/vendor/autoload.php';

use \phpCache\Cache;

$c = new Cache();

if(!$c->has("example")) {
  $c->set("example", 'cache data', 300); // cache result for 5 minutes (300 seconds)
} else {
  echo $c->get("example");
}

Example Two

$example = $c->get("example");

if($example !== false) {
  echo "Cached: " . $example;
  $c->remove("example"); // remove from cache
} else {
  echo "Cache not found or expired";
}

Example Three

$c->set("progress", 50, 300); // cache result for 5 minutes (300 seconds)

$progress = $c->get("progress", 0); // default return 0

echo "Progress: " . $progress;

Functions

__construct($name, $dir, $ext)

Class constructor

  • $name - name of the cache (default phpcache)
  • $dir - directory where the cache will be stored (default TEMP directory)
  • $ext - extension of the cache file (default .cache)

set($key, $value, $ttl = 0)

Writes data to cache

  • $key - key of the value
  • $value - value
  • $ttl - Time To Live (in how many seconds value will expire)

get($key, $default = false)

Reads data from cache

  • $key - key of the value
  • $default - is default value return if value by $key not found (default false)
  • return:
    • bool(false) - value not cached or expired
    • array - if success

remove($key)

Removes data from cache

  • $key - key of the value
  • return:
    • bool(false) - key not found
    • bool(true) - success

has($key)

Check exists and not is expired cache

  • $key - key of the value
  • return:
    • bool(false) - not found
    • bool(true) - is found

clean()

clean cache file

  • return:
    • bool(false) - fail
    • bool(true) - success

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固