func (r *Repository) Contains(key string) (ok bool) {
	_, ok = r.items[key]
	return ok
}
Contains checks if a key is in the cache, without updating the recent-ness
or deleting it for being stale.
package lru
import (
	"container/list"
	"encoding/json"
	"time"
	"github.com/bxcodec/gotcha/cache"
)
type Repository struct {
	maxSize              uint64
	maxMemory            uint64
	fragmentPositionList *list.List
	items                map[string]*list.Element
	expiryTresHold       time.Duration
}
func New(size, memory uint64, expiryTresHold time.Duration) *Repository {
	c := &Repository{
		maxSize:              size,
		fragmentPositionList: list.New(),
		items:                make(map[string]*list.Element),
		expiryTresHold:       expiryTresHold,
		maxMemory:            memory,
	}
	return c
}
func (r *Repository) Set(doc *cache.Document) (err error) {
	if elem, ok := r.items[doc.Key]; ok {
		r.fragmentPositionList.MoveToFront(elem)
		elem.Value = doc
		return nil
	}
	elem := r.fragmentPositionList.PushFront(doc)
	r.items[doc.Key] = elem
	if uint64(r.fragmentPositionList.Len()) > r.maxSize {
		r.removeOldest()
	}
	if r.maxMemory == 0 {
		return
	}
	byteMap, err := json.Marshal(r.items)
	if err != nil {
		r.Delete(doc.Key)
		return
	}
	if uint64(len(byteMap)) > r.maxMemory {
		r.removeOldest()
	}
	return
}
func (r *Repository) Get(key string) (res *cache.Document, err error) {
	if elem, ok := r.items[key]; ok {
		res = elem.Value.(*cache.Document)
		storedTime := time.Unix(res.StoredTime, 0)
		if time.Since(storedTime) > r.expiryTresHold {  
			_, err = r.Delete(key)
			return nil, cache.ErrMissed
		}
		r.fragmentPositionList.MoveToFront(elem)
		return
	}
	err = cache.ErrMissed
	return
}
func (r *Repository) GetOldest() (res *cache.Document, err error) {
	elem := r.fragmentPositionList.Back()
	if elem != nil {
		res = elem.Value.(*cache.Document)
		return
	}
	return
}