thinkphp5-缓存
缓存独立配置文件 extra/cache.php
<?php
return [
// 驱动方式,type为complex时为混合类型
'type' => 'complex',
// 默认使用的缓存
'default' => [
// 驱动方式
'type' => 'file',
'prefix' => '',
// 缓存保存目录
'path' => CACHE_PATH,
],
// 文件缓存
'file' => [
// 驱动方式
'type' => 'file',
// 缓存前缀
'prefix' => '',
// 设置不同的缓存保存目录
'path' => RUNTIME_PATH . 'file/',
// 缓存有效期 0表示永久缓存
'expire' => 0,
],
// redis缓存
'redis' => [
// 驱动方式
'type' => 'redis',
'port' => '6379',
// 服务器地址
'host' => '127.0.0.1',
// 缓存有效期 0表示永久缓存
'expire' => 0,
],
];
使用
cache('name','huyongjian',600);
echo cache('name');

浙公网安备 33010602011771号