mirror of
https://github.com/Luzifer/ots.git
synced 2025-08-02 11:16:25 -04:00
[#12] Add lazy-expiry to mem-storage, unify envvars
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
1a91a5d34d
commit
990fddff7a
3 changed files with 51 additions and 12 deletions
|
@ -65,12 +65,19 @@ func (s storageRedis) migrate() error {
|
|||
}
|
||||
|
||||
func (s storageRedis) redisExpiry() int {
|
||||
exp := os.Getenv("REDIS_EXPIRY")
|
||||
if exp == "" {
|
||||
var expStr string
|
||||
for _, eVar := range []string{"SECRET_EXPIRY", "REDIS_EXPIRY"} {
|
||||
if v := os.Getenv(eVar); v != "" {
|
||||
expStr = v
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if expStr == "" {
|
||||
return 0
|
||||
}
|
||||
|
||||
e, err := strconv.ParseInt(exp, 10, 64)
|
||||
e, err := strconv.ParseInt(expStr, 10, 64)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue