From 1496fcad0eeb5b533c6441409b22c0eccb125972 Mon Sep 17 00:00:00 2001 From: Tyler Date: Sat, 5 Oct 2019 16:15:19 -0400 Subject: [PATCH] Support direct []byte and string responses without dst on memory driver --- memory.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/memory.go b/memory.go index 0814251..0c842a9 100644 --- a/memory.go +++ b/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]