mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
优化
This commit is contained in:
31
pkg/cache/sub_device.go
vendored
Normal file
31
pkg/cache/sub_device.go
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"pandax/kit/cache"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var SubDeviceField = cache.NewTimedCache(cache.NoExpiration, 24*time.Hour)
|
||||
var SUBDEVICEKEY = "SUBDEVICEKEY"
|
||||
|
||||
func CheckSubDeviceField(field string) bool {
|
||||
fields, bool := SubDeviceField.Get(SUBDEVICEKEY)
|
||||
if !bool {
|
||||
return false
|
||||
}
|
||||
if !strings.Contains(fields.(string), field) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func SetSubDeviceField(data string) {
|
||||
fields, bool := SubDeviceField.Get(SUBDEVICEKEY)
|
||||
if !bool {
|
||||
fields = data
|
||||
} else {
|
||||
fields = fields.(string) + "," + data
|
||||
}
|
||||
ProductCache.Put(SUBDEVICEKEY, fields)
|
||||
}
|
||||
Reference in New Issue
Block a user