2dfe1fc6 by astaxie

Merge pull request #792 from haowang1013/develop

fixed uninitialized return error if StartAndGC fails
2 parents 6eee2233 29b60d60
...@@ -81,13 +81,13 @@ func Register(name string, adapter Cache) { ...@@ -81,13 +81,13 @@ func Register(name string, adapter Cache) {
81 // Create a new cache driver by adapter name and config string. 81 // Create a new cache driver by adapter name and config string.
82 // config need to be correct JSON as string: {"interval":360}. 82 // config need to be correct JSON as string: {"interval":360}.
83 // it will start gc automatically. 83 // it will start gc automatically.
84 func NewCache(adapterName, config string) (adapter Cache, e error) { 84 func NewCache(adapterName, config string) (adapter Cache, err error) {
85 adapter, ok := adapters[adapterName] 85 adapter, ok := adapters[adapterName]
86 if !ok { 86 if !ok {
87 e = fmt.Errorf("cache: unknown adapter name %q (forgot to import?)", adapterName) 87 err = fmt.Errorf("cache: unknown adapter name %q (forgot to import?)", adapterName)
88 return 88 return
89 } 89 }
90 err := adapter.StartAndGC(config) 90 err = adapter.StartAndGC(config)
91 if err != nil { 91 if err != nil {
92 adapter = nil 92 adapter = nil
93 } 93 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!