func (c *Cache) Get(key string) interface{} {
	e := c.entries[key]
	if e == nil {
		return nil
	}
	c.promote(e)
	return e.value
}
Get an entry from cache.
package lru
type entry struct {
	key   string
	value interface{}
	prev  *entry
	next  *entry
}
type Cache struct {
	entries map[string]*entry
	size    int
	onEvict func(key string, value interface{})
	head    *entry
	tail    *entry
}
func New(size int, onEvict func(key string, value interface{})) *Cache {
	if size <= 0 {
		panic("invalid size")
	}
	return &Cache{
		entries: make(map[string]*entry, int(float64(size)*1.5)),
		size:    size,
		onEvict: onEvict,
	}
}
func (c *Cache) Set(key string, value interface{}) {
	e := c.entries[key]
	if e == nil {
		e = &entry{key: key, value: value}
		c.entries[key] = e
		if c.head == nil {
			c.head = e
			c.tail = e
		} else {
			c.head.prev = e
			e.next = c.head
			c.head = e
		}
	} else {
		e.value = value
		c.promote(e)
	}
	if len(c.entries) > c.size {
		evicted := c.tail
		delete(c.entries, c.tail.key)
		c.tail = c.tail.prev
		c.tail.next = nil
		if c.onEvict != nil {
			c.onEvict(evicted.key, evicted.value)
		}
	}
}
func (c *Cache) promote(e *entry) {
	if c.head != e {
		if c.tail == e {
			c.tail = c.tail.prev
			c.tail.next = nil
		} else {
			e.prev.next = e.next
			e.next.prev = e.prev
		}
		e.prev = nil
		e.next = c.head
		c.head.prev = e
		c.head = e
	}
}
func (c *Cache) Len() int {
	return len(c.entries)
}