From 2a07db75c70206eb684c47479ac6ec01d6d35d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Tue, 6 Sep 2022 13:17:59 +0800 Subject: [PATCH] =?UTF-8?q?enhance(cache):=E5=88=A0=E9=99=A4=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E4=B8=8D=E5=86=8D=E4=BD=BF=E7=94=A8=E7=9A=84=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=96=B9=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cache/repository.go | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 cache/repository.go diff --git a/cache/repository.go b/cache/repository.go deleted file mode 100644 index 8242c0d..0000000 --- a/cache/repository.go +++ /dev/null @@ -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) - } -}