Support direct []byte and string responses without dst on memory driver
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Tyler 2019-10-05 16:15:19 -04:00
parent 1807721360
commit 1496fcad0e
1 changed files with 9 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package cache
import (
"errors"
"github.com/patrickmn/go-cache"
"github.com/vmihailenco/msgpack/v4"
"reflect"
"time"
)
@ -36,7 +37,14 @@ func (mc *MemoryCache) Get(key string, dst ...interface{}) ([]byte, error) {
}
if len(dst) == 0 {
return nil, ErrMemoryCacheNotSupported
switch item.(type) {
case string:
return []byte(item.(string)), nil
case []byte:
return item.([]byte), nil
}
return msgpack.Marshal(item)
}
v := dst[0]