From 2637438dbc5987e74e02ae1a71722f4ba4aa000f Mon Sep 17 00:00:00 2001 From: KJHJason Date: Tue, 21 May 2024 15:09:26 +0800 Subject: [PATCH] remove confusing key value struct --- database/post_cache.go | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/database/post_cache.go b/database/post_cache.go index 52fda31..d192989 100644 --- a/database/post_cache.go +++ b/database/post_cache.go @@ -202,44 +202,20 @@ func GetAllCacheForAllPlatforms() []*PostCache { return allCache } -type CacheKeyValue struct { - Key string `json:"Key"` - Val time.Time `json:"Val"` - Bucket string `json:"Bucket"` - CacheKey string `json:"CacheKey"` -} - -func newCacheKeyValues(cache []*KeyValue) []*CacheKeyValue { - if len(cache) == 0 { - return make([]*CacheKeyValue, 0) - } - - newCache := make([]*CacheKeyValue, 0, len(cache)) - for _, c := range cache { - newCache = append(newCache, &CacheKeyValue{ - Key: c.GetKey(), - Val: ParseBytesToDateTime([]byte(c.GetVal())), - Bucket: c.Bucket, - CacheKey: c.GetKey(), - }) - } - return newCache -} - func DeletePostCacheForAllPlatforms() error { return AppDb.DeleteBucket(POST_BUCKET) } -func GetAllGdriveCache() []*CacheKeyValue { - return newCacheKeyValues(AppDb.GetAllKeyValue(GDRIVE_BUCKET)) +func GetAllGdriveCache() []*KeyValue { + return AppDb.GetAllKeyValue(GDRIVE_BUCKET) } func DeleteAllGdriveCache() error { return AppDb.DeleteBucket(GDRIVE_BUCKET) } -func GetAllUgoiraCache() []*CacheKeyValue { - return newCacheKeyValues(AppDb.GetAllKeyValue(UGOIRA_BUCKET)) +func GetAllUgoiraCache() []*KeyValue { + return AppDb.GetAllKeyValue(UGOIRA_BUCKET) } func DeleteAllUgoiraCache() error {