func (s *Storage) Get(key string) ([]byte, error) {
	if len(key) <= 0 {
		return nil, nil
	}
	s.mux.RLock()
	v, ok := s.db[key]
	s.mux.RUnlock()
	if !ok || v.expiry != 0 && v.expiry <= uint32(time.Now().Unix()) {
		return nil, nil
	}
	return v.data, nil
}
Get value by key
package memory
import (
	"sync"
	"time"
)
type Storage struct {
	mux        sync.RWMutex
	db         map[string]entry
	gcInterval time.Duration
	done       chan struct{}
}
type entry struct {
	expiry uint32
	data   []byte
}
func New() *Storage {
	store := &Storage{
		db:         make(map[string]entry),
		gcInterval: 10 * time.Second,
		done:       make(chan struct{}),
	}
	go store.gc()
	return store
}