From e7a9def80f35fe1b170b7b8b68871d59dea117e1 Mon Sep 17 00:00:00 2001 From: Patrick Mylund Nielsen Date: Fri, 25 Nov 2016 18:48:19 -0500 Subject: [PATCH] Add SetDefault() for setting with the default expiration --- cache.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cache.go b/cache.go index 8c440d4..70e4dad 100644 --- a/cache.go +++ b/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 // key, or if the existing item has expired. Returns an error otherwise. func (c *cache) Add(k string, x interface{}, d time.Duration) error {