|
|
|
@ -99,13 +99,13 @@ func New(de, ci time.Duration) *Cache
|
|
|
|
|
before their next lookup or before calling DeleteExpired.
|
|
|
|
|
|
|
|
|
|
func (c *Cache) Set(k string, x interface{}, d time.Duration)
|
|
|
|
|
Adds an item to the cache, replacing any existing item. If the duration is 0,
|
|
|
|
|
the cache's default expiration time is used. If it is -1, the item never
|
|
|
|
|
Adds an item to the cache, replacing any existing item. If the duration is
|
|
|
|
|
0, the cache's default expiration time is used. If it is -1, the item never
|
|
|
|
|
expires.
|
|
|
|
|
|
|
|
|
|
func (c *Cache) Add(k string, x interface{}, d time.Duration) error
|
|
|
|
|
Adds 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 if not.
|
|
|
|
|
Adds 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 if not.
|
|
|
|
|
|
|
|
|
|
func (c *Cache) Replace(k string, x interface{}, d time.Duration) error
|
|
|
|
|
Sets a new value for the cache item only if it already exists. Returns an
|
|
|
|
@ -118,22 +118,22 @@ func (c *Cache) Get(k string) (interface{}, bool)
|
|
|
|
|
func (c *Cache) Increment(k string, n int64) error
|
|
|
|
|
Increment an item of type int, int8, int16, int32, int64, uintptr, uint,
|
|
|
|
|
uint8, uint32, or uint64, float32 or float64 by n. Returns an error if the
|
|
|
|
|
item's value is not an integer, if it was not found, or if it is not possible
|
|
|
|
|
to increment it by n. Passing a negative number will cause the item to be
|
|
|
|
|
decremented.
|
|
|
|
|
item's value is not an integer, if it was not found, or if it is not
|
|
|
|
|
possible to increment it by n. Passing a negative number will cause the item
|
|
|
|
|
to be decremented.
|
|
|
|
|
|
|
|
|
|
func (c *Cache) IncrementFloat(k string, n float64) error
|
|
|
|
|
Increment an item of type int, int8, int16, int32, int64, uintptr, uint,
|
|
|
|
|
uint8, uint32, or uint64, float32 or float64 by n. Returns an error if the
|
|
|
|
|
item's value is not an integer, if it was not found, or if it is not possible
|
|
|
|
|
to increment it by n. Passing a negative number will cause the item to be
|
|
|
|
|
decremented.
|
|
|
|
|
item's value is not an integer, if it was not found, or if it is not
|
|
|
|
|
possible to increment it by n. Passing a negative number will cause the item
|
|
|
|
|
to be decremented.
|
|
|
|
|
|
|
|
|
|
func (c *Cache) Decrement(k string, n int64) error
|
|
|
|
|
Decrement an item of type int, int8, int16, int32, int64, uintptr, uint,
|
|
|
|
|
uint8, uint32, or uint64, float32 or float64 by n. Returns an error if the
|
|
|
|
|
item's value is not an integer, if it was not found, or if it is not possible
|
|
|
|
|
to decrement it by n.
|
|
|
|
|
item's value is not an integer, if it was not found, or if it is not
|
|
|
|
|
possible to decrement it by n.
|
|
|
|
|
|
|
|
|
|
func (c *Cache) Delete(k string)
|
|
|
|
|
Deletes an item from the cache. Does nothing if the item does not exist in
|
|
|
|
@ -155,9 +155,9 @@ func (c *Cache) SaveFile(fname string) error
|
|
|
|
|
doesn't exist, and overwriting it if it does.
|
|
|
|
|
|
|
|
|
|
func (c *Cache) Load(r io.Reader) error
|
|
|
|
|
Adds (Gob-serialized) cache items from an io.Reader, excluding any items that
|
|
|
|
|
already exist in the current cache.
|
|
|
|
|
Adds (Gob-serialized) cache items from an io.Reader, excluding any items
|
|
|
|
|
that already exist in the current cache.
|
|
|
|
|
|
|
|
|
|
func (c *Cache) LoadFile(fname string) error
|
|
|
|
|
Loads and adds cache items from the given filename, excluding any items that
|
|
|
|
|
already exist in the current cache.
|
|
|
|
|
Loads and adds cache items from the given filename, excluding any items
|
|
|
|
|
that already exist in the current cache.
|
|
|
|
|