Cache.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Cache;
  12. use Psr\SimpleCache\CacheInterface;
  13. class Cache implements CacheInterface
  14. {
  15. protected $driver;
  16. public function __construct(CacheManager $manager)
  17. {
  18. $this->driver = $manager->getDriver();
  19. }
  20. public function __call($name, $arguments)
  21. {
  22. return $this->driver->{$name}(...$arguments);
  23. }
  24. public function get($key, $default = null)
  25. {
  26. return $this->__call(__FUNCTION__, func_get_args());
  27. }
  28. public function set($key, $value, $ttl = null)
  29. {
  30. return $this->__call(__FUNCTION__, func_get_args());
  31. }
  32. public function delete($key)
  33. {
  34. return $this->__call(__FUNCTION__, func_get_args());
  35. }
  36. public function clear()
  37. {
  38. return $this->__call(__FUNCTION__, func_get_args());
  39. }
  40. public function getMultiple($keys, $default = null)
  41. {
  42. return $this->__call(__FUNCTION__, func_get_args());
  43. }
  44. public function setMultiple($values, $ttl = null)
  45. {
  46. return $this->__call(__FUNCTION__, func_get_args());
  47. }
  48. public function deleteMultiple($keys)
  49. {
  50. return $this->__call(__FUNCTION__, func_get_args());
  51. }
  52. public function has($key)
  53. {
  54. return $this->__call(__FUNCTION__, func_get_args());
  55. }
  56. }