symfony cache for webman
composer require yzh52521/symfony-cache
config/cache.php
- apc
- array
- file 本地缓存
- redis 缓存
- memcached 缓存
- database 数据库缓存
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));
}
}
$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');