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>
This commit is contained in:
parent
3a4801d195
commit
30f7ddb833
7 changed files with 29 additions and 10 deletions
6
modules/cache/cache.go
vendored
6
modules/cache/cache.go
vendored
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue