package memory import "time" // Item represents an item stored in the cache. type Item struct { Value interface{} Expiration int64 } // Expired returns true if the item has expired. func (i *Item) Expired() bool { if i.Expiration == 0 { return false } return time.Now().UnixNano() > i.Expiration } // NewCache returns a new cache. func NewCache(opts ...Option) *memCache { options := NewOptions(opts...) items := make(map[string]Item) if len(options.Items) > 0 { items = options.Items } return &memCache{ opts: options, items: items, } }