mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-30 12:16:07 +01:00
fix (config): synchronise cache writes (#237)
Cache writes used in Config.Get() method wasn't synchronized. Use sync.Mutex to make it thread-save.
This commit is contained in:
parent
f3c4bdb8a8
commit
c117c99401
1 changed files with 2 additions and 0 deletions
|
|
@ -414,6 +414,7 @@ func (this *Configuration) Get(key string) *Configuration {
|
|||
}
|
||||
|
||||
// increase speed (x4 with our bench) by using a cache
|
||||
this.mu.Lock()
|
||||
tmp := this.cache.Get(key)
|
||||
if tmp == nil {
|
||||
this.currentElement = traverse(&this.form, strings.Split(key, "."))
|
||||
|
|
@ -421,6 +422,7 @@ func (this *Configuration) Get(key string) *Configuration {
|
|||
} else {
|
||||
this.currentElement = tmp.(*FormElement)
|
||||
}
|
||||
this.mu.Unlock()
|
||||
return this
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue