Merge pull request #821 from yunbj/redis-ttl

Set redis key ttl with entry.TTLSec
This commit is contained in:
Chris Lu 2019-01-08 20:18:41 -08:00 committed by GitHub
commit 528e594b01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,6 +7,7 @@ import (
"github.com/go-redis/redis"
"sort"
"strings"
"time"
)
const (
@ -24,7 +25,7 @@ func (store *UniversalRedisStore) InsertEntry(entry *filer2.Entry) (err error) {
return fmt.Errorf("encoding %s %+v: %v", entry.FullPath, entry.Attr, err)
}
_, err = store.Client.Set(string(entry.FullPath), value, 0).Result()
_, err = store.Client.Set(string(entry.FullPath), value, time.Duration(entry.TtlSec) * time.Second).Result()
if err != nil {
return fmt.Errorf("persisting %s : %v", entry.FullPath, err)