aboutsummaryrefslogtreecommitdiffstats
path: root/modules/cache
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-02-09 22:29:03 +0000
committerGitHub <noreply@github.com>2021-02-09 22:29:03 +0000
commit30f7ddb833adfe276a93c1a79e243b8d33bdd41e (patch)
tree923227416de1d00b9158a43e64dcb0ceac2d5023 /modules/cache
parent3a4801d1958ce33c9b893433c096281aa5b9b1c5 (diff)
downloadgitea-30f7ddb833adfe276a93c1a79e243b8d33bdd41e.tar.gz
gitea-30f7ddb833adfe276a93c1a79e243b8d33bdd41e.zip
Ensure memcache TTL cannot be over 30 days (#14592)
Memcached TTL cannot be > 30 days and if it is attempted the TTL is interpreted as a unix timestamp. This PR ensures that the TTL is switched to a unix timestamp in those cases. Fix #14571 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/cache')
-rw-r--r--modules/cache/cache.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/modules/cache/cache.go b/modules/cache/cache.go
index 609f5a242b..3a2732c343 100644
--- a/modules/cache/cache.go
+++ b/modules/cache/cache.go
@@ -58,7 +58,7 @@ func GetString(key string, getFunc func() (string, error)) (string, error) {
if value, err = getFunc(); err != nil {
return value, err
}
- err = conn.Put(key, value, int64(setting.CacheService.TTL.Seconds()))
+ err = conn.Put(key, value, setting.CacheService.TTLSeconds())
if err != nil {
return "", err
}
@@ -86,7 +86,7 @@ func GetInt(key string, getFunc func() (int, error)) (int, error) {
if value, err = getFunc(); err != nil {
return value, err
}
- err = conn.Put(key, value, int64(setting.CacheService.TTL.Seconds()))
+ err = conn.Put(key, value, setting.CacheService.TTLSeconds())
if err != nil {
return 0, err
}
@@ -118,7 +118,7 @@ func GetInt64(key string, getFunc func() (int64, error)) (int64, error) {
if value, err = getFunc(); err != nil {
return value, err
}
- err = conn.Put(key, value, int64(setting.CacheService.TTL.Seconds()))
+ err = conn.Put(key, value, setting.CacheService.TTLSeconds())
if err != nil {
return 0, err
}