summaryrefslogtreecommitdiffstats
path: root/modules/cache/cache.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-01-01 23:24:01 +0800
committerGitHub <noreply@github.com>2023-01-01 23:24:01 +0800
commit06970755470d24cbedbc9bcc26389fa52d2fe310 (patch)
treebcaba5381bed19aea66b57bfcf85530a1f0cbc37 /modules/cache/cache.go
parentf1e07d8c879aed32d079694d3623f9c6450ee8cd (diff)
downloadgitea-06970755470d24cbedbc9bcc26389fa52d2fe310.tar.gz
gitea-06970755470d24cbedbc9bcc26389fa52d2fe310.zip
Fix get system setting bug when enabled redis cache (#22298)
backport #22295, fix #22281 Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules/cache/cache.go')
-rw-r--r--modules/cache/cache.go33
1 files changed, 0 insertions, 33 deletions
diff --git a/modules/cache/cache.go b/modules/cache/cache.go
index d98b0a0cec..474ede3cf3 100644
--- a/modules/cache/cache.go
+++ b/modules/cache/cache.go
@@ -46,39 +46,6 @@ func GetCache() mc.Cache {
return conn
}
-// Get returns the key value from cache with callback when no key exists in cache
-func Get[V interface{}](key string, getFunc func() (V, error)) (V, error) {
- if conn == nil || setting.CacheService.TTL == 0 {
- return getFunc()
- }
-
- cached := conn.Get(key)
- if value, ok := cached.(V); ok {
- return value, nil
- }
-
- value, err := getFunc()
- if err != nil {
- return value, err
- }
-
- return value, conn.Put(key, value, setting.CacheService.TTLSeconds())
-}
-
-// Set updates and returns the key value in the cache with callback. The old value is only removed if the updateFunc() is successful
-func Set[V interface{}](key string, valueFunc func() (V, error)) (V, error) {
- if conn == nil || setting.CacheService.TTL == 0 {
- return valueFunc()
- }
-
- value, err := valueFunc()
- if err != nil {
- return value, err
- }
-
- return value, conn.Put(key, value, setting.CacheService.TTLSeconds())
-}
-
// GetString returns the key value from cache with callback when no key exists in cache
func GetString(key string, getFunc func() (string, error)) (string, error) {
if conn == nil || setting.CacheService.TTL == 0 {