by p1mrx · 11y ago · 0 comments
Also, the minimum/maximum timestamp and overflow behavior seem to be poorly-defined.
func (c *Cache) AddExpiring(k Key, e Entry, d time.Duration) {}
func (c *Cache) Add(k Key, e Entry) {}
func (c *Cache) GetWithRemaining(k Key) (e Entry, left time.Duration) {}
Not the prettiest, but it does the job. That sentence could be Go's motto.It's also not a great idea to manually define the largest possible timestamp as a sentinel, because Add(Duration) doesn't check for overflow.