Files
PandaX/pkg/cache/device_etoken.go
勤快的小晴同学 0d3bae0001 部分判断优化
Signed-off-by: 勤快的小晴同学 <941403820@qq.com>
2024-03-11 01:50:13 +00:00

30 lines
709 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
}