akalod/cache

该包的最新版本(dev-master)没有可用的许可证信息。

基本缓存模块

dev-master 2022-07-06 17:57 UTC

This package is auto-updated.

Last update: 2024-09-06 22:36:38 UTC


README

基本的redis缓存操作器

安装

composer require akalod/cache

示例

use Akalod/Cache;

//init redis connection
Cache::init(); //host, port, authPass, 

//set Default cacheTime
Cache::cacheTime = 200; 

//set 
Cache::set('key','value',400); // key, value, cacheTime

//get
Cache::get('key');

//set and get with callback example
$result = Cache::getSet('keyName', function () {
            //value
            return DB::table('pages')
                ->where('status', 1)
                ->where('group', 1)
                ->orderBy('short', 'asc')
                ->get(['seo', 'title', 'page_title']);
    }, 700); //key, callback, cacheTime