think-cache.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. return [
  3. // 默认缓存驱动
  4. 'default' => 'redis',
  5. // 缓存连接方式配置
  6. 'stores' => [
  7. // redis缓存
  8. 'redis' => [
  9. // 驱动方式
  10. 'type' => 'redis',
  11. // 服务器地址
  12. 'host' => '127.0.0.1',
  13. // 无 ACL 用户请留空 username(Redis 6.0 起支持用户名 + 密码认证)
  14. 'username' => '',
  15. // redis密码
  16. 'password' => '',
  17. // 选择的数据库索引
  18. 'select' => 0,
  19. // 缓存前缀
  20. 'prefix' => 'cache:',
  21. // 默认缓存有效期 0表示永久缓存
  22. 'expire' => 0,
  23. // Thinkphp官方没有这个参数,由于生成的tag键默认不过期,如果tag键数量很大,避免长时间占用内存,可以设置一个超过其他缓存的过期时间,0为不设置
  24. 'tag_expire' => 86400 * 30,
  25. // 缓存标签前缀
  26. 'tag_prefix' => 'tag:',
  27. // 连接池配置
  28. 'pool' => [
  29. 'max_connections' => 5, // 最大连接数
  30. 'min_connections' => 1, // 最小连接数
  31. 'wait_timeout' => 3, // 从连接池获取连接等待超时时间
  32. 'idle_timeout' => 60, // 连接最大空闲时间,超过该时间会被回收
  33. 'heartbeat_interval' => 50, // 心跳检测间隔,需要小于60秒
  34. ],
  35. ],
  36. // 文件缓存
  37. 'file' => [
  38. // 驱动方式
  39. 'type' => 'file',
  40. // 设置不同的缓存保存目录
  41. 'path' => runtime_path() . '/file/',
  42. ],
  43. ],
  44. ];