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
}
Set adds a value to the cache.  Returns true if an eviction occurred.
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
}