时间选定库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
374 B

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
}