Implement store read cache (#1366)

* Implement store read cache

* Added cache tests and fixed a bug in memory store
This commit is contained in:
Jake Sanders
2020-03-19 18:19:07 +00:00
committed by GitHub
parent cbb958def5
commit 4c6f68d537
3 changed files with 231 additions and 1 deletions

View File

@@ -106,7 +106,9 @@ func (m *memoryStore) get(k string) (*store.Record, error) {
newRecord.Key = storedRecord.key
newRecord.Value = make([]byte, len(storedRecord.value))
copy(newRecord.Value, storedRecord.value)
newRecord.Expiry = time.Until(storedRecord.expiresAt)
if !storedRecord.expiresAt.IsZero() {
newRecord.Expiry = time.Until(storedRecord.expiresAt)
}
return newRecord, nil
}