diff --git a/memory.go b/memory.go index 6f3001d..0814251 100644 --- a/memory.go +++ b/memory.go @@ -8,7 +8,8 @@ import ( ) var ( - MemoryCacheNotExists = errors.New("item does not exist") + ErrMemoryCacheNotExists = errors.New("item does not exist") + ErrMemoryCacheNotSupported = errors.New("memory cache does not support retrieving items without a destination pointer") ) type MemoryCache struct { @@ -31,7 +32,11 @@ func (mc *MemoryCache) Get(key string, dst ...interface{}) ([]byte, error) { item, exists := mc.c.Get(key) if !exists { - return nil, MemoryCacheNotExists + return nil, ErrMemoryCacheNotExists + } + + if len(dst) == 0 { + return nil, ErrMemoryCacheNotSupported } v := dst[0]