enhance(cache):删除已经不再使用的缓存方法。
This commit is contained in:
parent
60280d0e06
commit
2a07db75c7
33
cache/repository.go
vendored
33
cache/repository.go
vendored
@ -1,33 +0,0 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"electricity_bill_calc/config"
|
||||
)
|
||||
|
||||
func CacheData[T interface{}](instance T, category string, key ...string) error {
|
||||
var keys = make([]string, 0)
|
||||
keys = append(keys, category)
|
||||
keys = append(keys, key...)
|
||||
cacheKey := CacheKey("cache", keys...)
|
||||
if exists, _ := Exists(cacheKey); exists {
|
||||
Delete(cacheKey)
|
||||
}
|
||||
return Cache(cacheKey, &instance, config.ServiceSettings.CacheLifeTime)
|
||||
}
|
||||
|
||||
func RetreiveData[T interface{}](category string, key ...string) (*T, error) {
|
||||
var keys = make([]string, 0)
|
||||
keys = append(keys, category)
|
||||
keys = append(keys, key...)
|
||||
return Retreive[T](CacheKey("cache", keys...))
|
||||
}
|
||||
|
||||
func AbolishCacheData(category string, key ...string) {
|
||||
var keys = make([]string, 0)
|
||||
keys = append(keys, category)
|
||||
keys = append(keys, key...)
|
||||
cacheKey := CacheKey("cache", keys...)
|
||||
if exists, _ := Exists(cacheKey); exists {
|
||||
Delete(cacheKey)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user