Skip to content

Commit

Permalink
Update connection cache to add short delay after 'set' call, ensuring…
Browse files Browse the repository at this point in the history
… results are available if read back immediately. Closes #90
  • Loading branch information
kaidaguerre committed Apr 8, 2021
1 parent 295a219 commit 0324ad4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions connection/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0324ad4

Please sign in to comment.