sm
/
cache
1
0
Fork 0

Clarify NewFrom documentation on use cases

This commit is contained in:
Patrick Mylund Nielsen 2014-12-22 02:15:12 -05:00
parent d68800e607
commit bc36de7dec
1 changed files with 4 additions and 4 deletions

View File

@ -1003,10 +1003,10 @@ func New(defaultExpiration, cleanupInterval time.Duration) *Cache {
// deleted from the cache before calling c.DeleteExpired().
//
// NewFrom also accepts an items map which will serve as the underlying map
// for the cache. This is useful for deserializing a cache (serialized using
// e.g. gob.Encode on c.Items()), or setting a starting size by passing in e.g.
// make(map[string]*Item, 500) to avoid repeat initial resizing of a map that's
// expected to reach a certain minimum size.
// for the cache. This is useful for starting from a deserialized cache
// (serialized using e.g. gob.Encode() on c.Items()), or passing in e.g.
// make(map[string]*Item, 500) to improve startup performance when the cache
// is expected to reach a certain minimum size.
//
// Only the cache's methods synchronize access to this map, so it is not
// recommended to keep any references to the map around after creating a cache.