Support direct []byte and string responses without dst on memory driver
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
1807721360
commit
1496fcad0e
10
memory.go
10
memory.go
|
@ -3,6 +3,7 @@ package cache
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/patrickmn/go-cache"
|
"github.com/patrickmn/go-cache"
|
||||||
|
"github.com/vmihailenco/msgpack/v4"
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -36,7 +37,14 @@ func (mc *MemoryCache) Get(key string, dst ...interface{}) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(dst) == 0 {
|
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]
|
v := dst[0]
|
||||||
|
|
Loading…
Reference in New Issue