mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
30 lines
709 B
Go
30 lines
709 B
Go
package cache
|
||
|
||
import (
|
||
"context"
|
||
"pandax/kit/rediscli"
|
||
"time"
|
||
)
|
||
|
||
var RedisDb *rediscli.RedisDB
|
||
|
||
// SetDeviceEtoken key 是设备的时候为token, 是子设备的时候为设备编码
|
||
func SetDeviceEtoken(key string, value any, duration time.Duration) error {
|
||
return RedisDb.Set(key, value, duration)
|
||
}
|
||
|
||
// GetDeviceEtoken value 是参数指针
|
||
func GetDeviceEtoken(key string, value interface{}) error {
|
||
return RedisDb.Get(key, value)
|
||
}
|
||
|
||
// DelDeviceEtoken 删除指定的key
|
||
func DelDeviceEtoken(key string) error {
|
||
return RedisDb.Del(context.Background(), key).Err()
|
||
}
|
||
|
||
func ExistsDeviceEtoken(key string) bool {
|
||
exists, _ := RedisDb.Exists(RedisDb.Context(), key).Result()
|
||
return exists == 1
|
||
}
|