package time_arrow import "time" type cache struct { Expired time.Time Data string } func (c *cache) IsExpired() bool { return c.Expired.Before(time.Now()) } func (c *cache) SetData(data string, duration time.Duration) { c.Data = data c.Expired = time.Now().Add(duration) } func (c *cache) GetData() string { if c.IsExpired() { return "" } return c.Data }