chrisullyott / simple-cache
在文件系统中快速简单地进行数据缓存。
v1.2.0
2020-10-23 18:33 UTC
Requires
- php: >=5.6.0
- chrisullyott/php-log: ^2.0
Requires (Dev)
- phpunit/phpunit: ^5
README
在文件系统中快速简单地进行数据缓存。
安装
$ composer require chrisullyott/simple-cache
实例化
require 'vendor/autoload.php'; use ChrisUllyott\Cache; $cache = new Cache('cache_id');
设置数据
$cache->set("Some data");
获取数据
echo $cache->get(); // "Some data"
清除
$cache->clear();
用法
<?php require 'vendor/autoload.php'; use ChrisUllyott\Cache; $cache = new Cache('my_key'); $data = $cache->get(); if (!$data) { $data = my_api_request(); $cache->set($data); } print_r($data);
测试
$ ./vendor/bin/phpunit --configuration=./tests/phpunit.xml