update expiry only if it is non-zero

This commit is contained in:
magodo 2019-07-11 12:58:20 +08:00
parent 3abe3aa28b
commit c8d57032bc

View File

@ -38,8 +38,10 @@ func (m *memoryStore) Dump() ([]*store.Record, error) {
}
// update expiry
v.r.Expiry -= t
v.c = time.Now()
if d > time.Duration(0) {
v.r.Expiry -= t
v.c = time.Now()
}
values = append(values, v.r)
}
@ -66,8 +68,10 @@ func (m *memoryStore) Read(key string) (*store.Record, error) {
}
// update expiry
v.r.Expiry -= t
v.c = time.Now()
if d > time.Duration(0) {
v.r.Expiry -= t
v.c = time.Now()
}
return v.r, nil
}