think-cache.php 1.4 KB

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