From bdeae91063d1a6c2639a01829fd81d548cbcef4f Mon Sep 17 00:00:00 2001 From: magodo Date: Thu, 11 Jul 2019 14:13:58 +0800 Subject: [PATCH] condense code --- data/store/memory/memory.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/data/store/memory/memory.go b/data/store/memory/memory.go index 75aafce0..bb7892e8 100644 --- a/data/store/memory/memory.go +++ b/data/store/memory/memory.go @@ -32,13 +32,12 @@ func (m *memoryStore) Dump() ([]*store.Record, error) { d := v.r.Expiry t := time.Since(v.c) - // expired - if d > time.Duration(0) && t > d { - continue - } - - // update expiry if d > time.Duration(0) { + // expired + if t > d { + continue + } + // update expiry v.r.Expiry -= t v.c = time.Now() } @@ -63,12 +62,11 @@ func (m *memoryStore) Read(key string) (*store.Record, error) { t := time.Since(v.c) // expired - if d > time.Duration(0) && t > d { - return nil, store.ErrNotFound - } - - // update expiry if d > time.Duration(0) { + if t > d { + return nil, store.ErrNotFound + } + // update expiry v.r.Expiry -= t v.c = time.Now() }