InfoCache.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\common\cache;
  3. /**
  4. * Info信息缓存类
  5. * Class InfoCache
  6. * @package app\common\cache
  7. */
  8. class InfoCache extends BaseCache
  9. {
  10. protected $tagName = 'info';
  11. /**
  12. * @notes 获取Info详情缓存
  13. * @param $id
  14. * @return false|mixed
  15. * @author Tab
  16. * @date 2021/7/14 15:13
  17. */
  18. public function getInfoDetail($id)
  19. {
  20. $cacheKey = $this->tagName . '_detail_' . $id;
  21. $info = $this->get($cacheKey);
  22. if($info) {
  23. return $info;
  24. }
  25. return false;
  26. }
  27. /**
  28. * @notes 设置Info详情缓存
  29. * @param $id
  30. * @param $data
  31. * @param int $expire 缓存过期时间,默认1小时
  32. * @author Tab
  33. * @date 2021/7/14 15:13
  34. */
  35. public function setInfoDetail($id, $data, $expire = 3600)
  36. {
  37. $cacheKey = $this->tagName . '_detail_' . $id;
  38. $this->set($cacheKey, $data, $expire);
  39. }
  40. /**
  41. * @notes 删除Info详情缓存
  42. * @param $id
  43. * @author Tab
  44. * @date 2021/7/14 15:13
  45. */
  46. public function deleteInfoDetail($id)
  47. {
  48. $cacheKey = $this->tagName . '_detail_' . $id;
  49. $this->delete($cacheKey);
  50. }
  51. }