1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-18 13:44:13 +00:00

fixed uninitialized return error if StartAndGC fails

This commit is contained in:
Wang Hao 2014-09-03 22:43:06 +08:00
parent 6eee223352
commit 29b60d6058

6
cache/cache.go vendored
View File

@ -81,13 +81,13 @@ func Register(name string, adapter Cache) {
// Create a new cache driver by adapter name and config string.
// config need to be correct JSON as string: {"interval":360}.
// 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]
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
}
err := adapter.StartAndGC(config)
err = adapter.StartAndGC(config)
if err != nil {
adapter = nil
}