-
Notifications
You must be signed in to change notification settings - Fork 0
cache
Joe Huss edited this page Nov 10, 2022
·
1 revision
在webmannative templates symfony/cacheascacheComponent。
The redis extension must be installed for
php-clibefore usingsymfony/cache。
php 7.x
composer require psr/container ^1.1.1 illuminate/redis ^8.2.0 symfony/cache ^5.2php 8.x
composer require psr/container ^1.1.1 illuminate/redis symfony/cacheredisConfiguration file inconfig/redis.php
return [
'default' => [
'host' => '127.0.0.1',
'password' => null,
'port' => 6379,
'database' => 0,
]
];<?php
namespace app\controller;
use support\Request;
use support\Cache;
class UserController
{
public function db(Request $request)
{
$key = 'test_key';
Cache::set($key, rand());
return response(Cache::get($key));
}
}Note keyTry to add a prefix to avoid conflicts with other businesses that use redis
ThinkCachee.g. statistics about a Define routes in