KeyTrait.php 803 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace tw\redis\traits;
  3. use tw\redis\TwRedis;
  4. trait KeyTrait
  5. {
  6. public function keys(string $pattern) : array
  7. {
  8. return TwRedis::keys($pattern);
  9. }
  10. public function expire($word, int $secs) : bool
  11. {
  12. return TwRedis::expire($this->key($word), $secs);
  13. }
  14. /**
  15. * 设置超时时间戳,到达该时间戳后,key 失效
  16. */
  17. public function expire_at($word, int $ts) : bool
  18. {
  19. return TwRedis::expireAt($this->key($word), $ts);
  20. }
  21. public function del($word) : int
  22. {
  23. return TwRedis::del($this->key($word));
  24. }
  25. public function type($word)
  26. {
  27. return TwRedis::type($this->key($word));
  28. }
  29. public function exists($word) : int
  30. {
  31. return TwRedis::exists($this->key($word));
  32. }
  33. }