peterujah/cache
Composer 安装命令:
composer require peterujah/cache
包简介
Cache - a simple php caching.
README 文档
README
A simple php file cache. The Cache is designed to simplify the process of caching data in PHP applications. It provides various methods for configuration, data caching, retrieval, and cache management. It helps to reduce database queries, API calls, or expensive computations by storing the results in the cache.
Installation
Installation is super-easy via Composer:
composer require peterujah/cache
USAGES
Initialize DBController with configuration array
use Peterujah\NanoBlock\Cache; $cache = new Cache("CACHE_NAME", __DIR__ . "/temp/caches/");
Query database and save response for later use
$cache->setExpire(7200); $user = $cache->onExpired("LIST", function () use($connConfig, $user_id){ $conn_handler = new Peterujah\NanoBlock\DBController($connConfig); $conn_handler->prepare(' SELECT * FROM user_table WHERE user_id = :fund_user_id LIMIT 1 '); $conn_handler->bind(':fund_user_id', $user_id); $conn_handler->execute(); $user = $conn_handler->getOne(); $conn_handler->free(); return array( "user" => $user, "time" => time(), "morething" => "More" ); });
Sets the cache debugging mode, the default is false
$cache->setDebugMode(true|false);
Sets the cache file extension type default is JSON
$cache->setExtension(Cache::PHP | Cache::JSON | Cache::TEXT);
Enable the cache to store secure data available only with php file extension, the default is true.
$cache->enableSecureAccess(true | false);
统计信息
- 总下载量: 44
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-12-21