Note about needing explicit synchronization if you want to use the returned items map and its cache at the same time

master
Patrick Mylund Nielsen 11 years ago
parent 3ff6a5407e
commit 7d1d6d6ae9

@ -936,7 +936,9 @@ func (c *cache) LoadFile(fname string) error {
// Returns the items in the cache. This may include items that have expired, // Returns the items in the cache. This may include items that have expired,
// but have not yet been cleaned up. If this is significant, the Expiration // but have not yet been cleaned up. If this is significant, the Expiration
// fields of the items should be checked. // fields of the items should be checked. Note that explicit synchronization
// is needed to use a cache and its corresponding Items() return value at
// the same time, as the map is shared.
func (c *cache) Items() map[string]*Item { func (c *cache) Items() map[string]*Item {
c.RLock() c.RLock()
defer c.RUnlock() defer c.RUnlock()

Loading…
Cancel
Save