fix golint issues in core/stores (#527)
This commit is contained in:
@@ -12,13 +12,16 @@ var (
|
||||
)
|
||||
|
||||
type (
|
||||
// Map is an alias of map[string]string.
|
||||
Map map[string]string
|
||||
|
||||
// A ScriptCache is a cache that stores a script with its sha key.
|
||||
ScriptCache struct {
|
||||
atomic.Value
|
||||
}
|
||||
)
|
||||
|
||||
// GetScriptCache returns a ScriptCache.
|
||||
func GetScriptCache() *ScriptCache {
|
||||
once.Do(func() {
|
||||
instance = &ScriptCache{}
|
||||
@@ -28,12 +31,14 @@ func GetScriptCache() *ScriptCache {
|
||||
return instance
|
||||
}
|
||||
|
||||
// GetSha returns the sha string of given script.
|
||||
func (sc *ScriptCache) GetSha(script string) (string, bool) {
|
||||
cache := sc.Load().(Map)
|
||||
ret, ok := cache[script]
|
||||
return ret, ok
|
||||
}
|
||||
|
||||
// SetSha sets script with sha into the ScriptCache.
|
||||
func (sc *ScriptCache) SetSha(script, sha string) {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user