symfony cache 緩存系統(tǒng)支持本地files/redis/memcached/database

v1.0.2
版本
2023-03-17
版本更新時(shí)間
108
安裝
3
star
簡(jiǎn)介
symfony/cache
安裝
composer require yzh52521/symfony-cache
配置文件
config/cache.php
支持驅(qū)動(dòng)
- apc
- array
- file 本地緩存
- redis 緩存
- memcached 緩存
- database 數(shù)據(jù)庫(kù)緩存
使用
namespace app\controller;
use support\Request;
use yzh52521\SymfonyCache\Cache;
class UserController
{
public function db(Request $request)
{
$key = 'test_key';
Cache::set($key, rand());
return response(Cache::get($key));
}
}
訪(fǎng)問(wèn)多個(gè)緩存存儲(chǔ)
$value = Cache::store('file')->get('foo');
Cache::store('redis')->set('bar', 'baz', 600); // 10 Minutes
從緩存中檢索
$value = Cache::get('key');
$value = Cache::get('key', 'default');
檢查是否存在
if (Cache::has('key')) {
//
}
刪除
Cache::delete('key');