Support direct []byte and string responses without dst on memory driver
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
1807721360
commit
1496fcad0e
10
memory.go
10
memory.go
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user