| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace tw\redis;
- use crmeb\utils\Redis;
- trait HashTrait
- {
- public function get($word, $attr) : string
- {
- return Redis::hGet($this->key($word), $attr);
- }
- public function gets($word, $attrs) : array
- {
- return Redis::hMGet($this->key($word), $attrs);
- }
- public function set($word, $attr, $value) : bool
- {
- return Redis::hSet($this->key($word), $attr, $value);
- }
- public function sets($word, $attrs) : bool
- {
- return Redis::hMSet($this->key($word), $attrs);
- }
- public function dels($word, $attrs) : int
- {
- if (is_string($attrs)) {
- return Redis::hDel($this->key($word), $attrs);
- }else if (is_array($attrs)) {
- return Redis::hDel($this->key($word), ...$attrs);
- }
- }
- public function getAll($word) : array
- {
- return Redis::hGetAll($this->key($word));
- }
- }
|