sm
/
cache
1
0
Fork 0

Stay below 80 characters in width in the README as well

This commit is contained in:
Patrick Mylund Nielsen 2012-06-22 04:04:21 +01:00
parent 026efae39f
commit 2b93e5eceb
1 changed files with 16 additions and 16 deletions

32
README
View File

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