cache tag php,ThinkPHP5缓存Cache的用法

hinkPHP采用think\Cache类提供缓存功能支持。

版本

新增功能

5.0.11

缓存设置方法有效期支持指定过期时间(DateTime)

5.0.2

增加remember方法

设置

缓存支持采用驱动方式,所以缓存在使用之前,需要进行连接操作,也就是缓存初始化操作。

$options = [

// 缓存类型为File

'type' => 'File',

// 缓存有效期为永久有效

'expire'=> 0,

//缓存前缀

'prefix'=> 'think',

// 指定缓存目录

'path' => APP_PATH.'runtime/cache/',

];

Cache::connect($options);

或者通过定义配置参数的方式,在应用配置文件中添加:

'cache' => [

'type' => 'File',

'path' => CACHE_PATH,

'prefix' => '',

'expire' => 0,

],

支持的缓存类型包括file、memcache、wincache、sqlite、redis和xcache。

缓存参数根据不同的缓存方式会有所区别&#

你可能感兴趣的:(cache,tag,php)