Add SetDefault() for setting with the default expiration
This commit is contained in:
parent
52581776a3
commit
e7a9def80f
6
cache.go
6
cache.go
@ -81,6 +81,12 @@ func (c *cache) set(k string, x interface{}, d time.Duration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add an item to the cache, replacing any existing item, using the default
|
||||||
|
// expiration.
|
||||||
|
func (c *cache) SetDefault(k string, x interface{}) {
|
||||||
|
c.Set(k, x, DefaultExpiration)
|
||||||
|
}
|
||||||
|
|
||||||
// Add an item to the cache only if an item doesn't already exist for the given
|
// Add an item to the cache only if an item doesn't already exist for the given
|
||||||
// key, or if the existing item has expired. Returns an error otherwise.
|
// key, or if the existing item has expired. Returns an error otherwise.
|
||||||
func (c *cache) Add(k string, x interface{}, d time.Duration) error {
|
func (c *cache) Add(k string, x interface{}, d time.Duration) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user