fix (cache): fix concurrency issue where our mutex wasn't lock properly

This commit is contained in:
=
2019-04-15 13:09:44 +10:00
parent 762977190d
commit a17dd11ce6
+2 -2
View File
@@ -86,7 +86,7 @@ func NewKeyValueStore() KeyValueStore {
return KeyValueStore{ cache: make(map[string]interface{}) }
}
func (this KeyValueStore) Get(key string) interface{} {
func (this *KeyValueStore) Get(key string) interface{} {
this.Lock()
val := this.cache[key]
this.Unlock()
@@ -101,6 +101,6 @@ func (this *KeyValueStore) Set(key string, value interface{}) {
func (this *KeyValueStore) Clear() {
this.Lock()
defer this.Unlock()
this.cache = make(map[string]interface{})
this.Unlock()
}