RedisCacheService.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace crmeb\services;
  12. use think\facade\Cache;
  13. /**
  14. * crmeb 缓存类
  15. * Class CacheService
  16. * @package crmeb\services
  17. * @mixin \Redis
  18. * @mixin \think\cache\driver\Redis
  19. */
  20. class RedisCacheService
  21. {
  22. /**
  23. * @var \Redis
  24. */
  25. protected $handler;
  26. /**
  27. * @var \think\cache\driver\Redis
  28. */
  29. protected $driver;
  30. /**
  31. * @param int $admin
  32. * @param string $tag
  33. */
  34. public function __construct()
  35. {
  36. $this->driver = Cache::store('redis');
  37. $this->handler = $this->driver->handler();
  38. }
  39. public function handler()
  40. {
  41. return $this->handler;
  42. }
  43. public function driver()
  44. {
  45. return $this->driver;
  46. }
  47. public function __call($name, $arguments)
  48. {
  49. if (method_exists($this->driver, $name)) {
  50. return call_user_func_array([$this->driver, $name], $arguments);
  51. }
  52. return call_user_func_array([$this->handler, $name], $arguments);
  53. }
  54. }