mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 16:32:31 +01:00
improve (lock): leverage RWLock
This commit is contained in:
parent
1c24026925
commit
eeef0f174c
1 changed files with 3 additions and 3 deletions
|
|
@ -79,7 +79,7 @@ func NewQuickCache(arg ...time.Duration) AppCache {
|
||||||
|
|
||||||
type KeyValueStore struct {
|
type KeyValueStore struct {
|
||||||
cache map[string]interface{}
|
cache map[string]interface{}
|
||||||
sync.Mutex
|
sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewKeyValueStore() KeyValueStore {
|
func NewKeyValueStore() KeyValueStore {
|
||||||
|
|
@ -87,9 +87,9 @@ func NewKeyValueStore() KeyValueStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *KeyValueStore) Get(key string) interface{} {
|
func (this *KeyValueStore) Get(key string) interface{} {
|
||||||
this.Lock()
|
this.RLock()
|
||||||
val := this.cache[key]
|
val := this.cache[key]
|
||||||
this.Unlock()
|
this.RUnlock()
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue