mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-31 01:58:11 +08:00
fix (concurrency): fix concurrency problem
This commit is contained in:
@ -3,7 +3,6 @@ package common
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"sync"
|
||||
)
|
||||
|
||||
func NewBool(t bool) *bool {
|
||||
@ -67,30 +66,3 @@ func PrettyPrint(json_dirty []byte) []byte {
|
||||
json_pretty.Write([]byte("\n"))
|
||||
return json_pretty.Bytes()
|
||||
}
|
||||
|
||||
type SafeMapStringString struct {
|
||||
sync.RWMutex
|
||||
internal map[string]string
|
||||
}
|
||||
|
||||
func NewSafeMapStringString() SafeMapStringString {
|
||||
return SafeMapStringString{
|
||||
internal: make(map[string]string),
|
||||
}
|
||||
}
|
||||
|
||||
func(this SafeMapStringString) Set(key string, value string) {
|
||||
this.Lock()
|
||||
this.internal[key] = value
|
||||
this.Unlock()
|
||||
}
|
||||
|
||||
func(this SafeMapStringString) Gets(keys ...string) []string{
|
||||
this.RLock()
|
||||
res := make([]string, len(keys))
|
||||
for i, key := range keys {
|
||||
res[i] = this.internal[key]
|
||||
}
|
||||
this.RUnlock()
|
||||
return res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user