Commit 2dfe1fc6 authored by astaxie's avatar astaxie

Merge pull request #792 from haowang1013/develop

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