From c8d57032bcdaf201ac09480bba2be5dc04bfd3c7 Mon Sep 17 00:00:00 2001 From: magodo Date: Thu, 11 Jul 2019 12:58:20 +0800 Subject: [PATCH] update expiry only if it is non-zero --- data/store/memory/memory.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/data/store/memory/memory.go b/data/store/memory/memory.go index 16f68136..75aafce0 100644 --- a/data/store/memory/memory.go +++ b/data/store/memory/memory.go @@ -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 }