Db::table('user')->cache(60)->find();
這樣調(diào)用后發(fā)現(xiàn)沒有生成緩存文件?
直接用用這個(gè)組件 Illuminate\Cache
在 support\bootstrap\db\Thinkphp.php
use Illuminate\Cache\RedisStore;
use support\bootstrap\Redis;
// 進(jìn)程啟動(dòng)時(shí)調(diào)用
public static function start($worker)
{
Db::setConfig(config('thinkorm'));
$cache = new RedisStore(Redis::$_manager); // 注意把 $_manager 改成 public
Db::setCache($cache);
}
"symfony/cache": "^5.2"
<?php
namespace support\bootstrap\db;
use Webman\Bootstrap;
use think\facade\Db;
use support\bootstrap\Redis;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Psr16Cache;
class Thinkphp implements Bootstrap
{
// 進(jìn)程啟動(dòng)時(shí)調(diào)用
public static function start($worker)
{
Db::setConfig(config('thinkorm'));
$adapter = new RedisAdapter(Redis::connection()->client());
$pool = new Psr16Cache($adapter);
Db::setCache($pool);
}
}
@7457:Symfony\Component\Cache\Exception\InvalidArgumentException: Cache key "127.0.0.1:3306@lanjinghai.yh_user" contains reserved characters "{}()/\@:". in /www/wwwroot/lanjinghai/vendor/symfony/cache/CacheItem.php:167