From 0324ad4d0ab0865e32caf2bcc4a81eb29ecc09f1 Mon Sep 17 00:00:00 2001 From: kai Date: Thu, 8 Apr 2021 17:12:44 +0100 Subject: [PATCH] Update connection cache to add short delay after 'set' call, ensuring results are available if read back immediately. Closes #90 --- connection/cache.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/connection/cache.go b/connection/cache.go index 47a58196..ba4fe01e 100644 --- a/connection/cache.go +++ b/connection/cache.go @@ -26,9 +26,12 @@ func NewCache(config *ristretto.Config) *Cache { return &Cache{cache} } -func (cache *Cache) Set(key string, value interface{}) { +func (cache *Cache) Set(key string, value interface{}) bool { ttl := 1 * time.Hour - cache.cache.SetWithTTL(key, value, 1, ttl) + res := cache.cache.SetWithTTL(key, value, 1, ttl) + // wait for value to pass through buffers + time.Sleep(10 * time.Millisecond) + return res } func (cache *Cache) Get(key string) (interface{}, bool) {