func (c *MemCache) DeleteExpired() {
	c.items.Range(func(key, value interface{}) bool {
		v := value.(*Item)
		k := key.(string)
		if v.Outdated() {
			c.items.Delete(k)
		}
		return true
	})
}
Delete all expired items from the memcache.
package cache
import (
	"sync"
	"time"
)
type MemCache struct {
	items sync.Map
	ci    time.Duration
}
func NewMemCache(ci time.Duration) *MemCache {
	c := &MemCache{
		items: sync.Map{},
		ci:    ci,
	}
	go c.runJanitor()
	return c
}
func (c *MemCache) Load(k string) (*Item, bool) {
	it, exists := c.Get(k)
	if !exists {
		return nil, false
	}
	return it, !it.Outdated()
}
func (c *MemCache) Get(k string) (*Item, bool) {
	tmp, found := c.items.Load(k)
	if !found {
		return nil, false
	}
	item := tmp.(*Item)
	if item.Expiration > 0 {
		if time.Now().UnixNano() > item.Expiration {
			return nil, false
		}
	}
	return item, true
}
func (c *MemCache) Set(k string, it *Item) {
	c.items.Store(k, it)
}
func (c *MemCache) Delete(k string) {
	c.items.Delete(k)
}
func (c *MemCache) runJanitor() {
	ticker := time.NewTicker(c.ci)
	defer ticker.Stop()
	for {
		select {
		case <-ticker.C:
			c.DeleteExpired()
		}
	}
}