Files
PandaX/pkg/cache/device_etoken.go
PandaX-Go 77ac18c21b [优化]
2024-08-25 19:58:05 +08:00

30 lines
727 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"
"github.com/PandaXGO/PandaKit/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
}