func (c *Cache) has(key string) (*sync.Mutex, bool) {
	hashValue := calcHash(key)

	c.mutex.Lock()
	defer c.mutex.Unlock()

	// If the resource is busy, wait for it to be free. This is the case if
	// the resource is currently being cached as a result of another request.
	// Also, release the lock on the cache to allow other readers while waiting
	if lock, busy := c.busyValues[hashValue]; busy {
		c.mutex.Unlock()
		lock.Lock()
		lock.Unlock()
		c.mutex.Lock()
	}

	// If a resource is in the shared cache, it can't be reserved. One can simply
	// access it directly from the cache
	if _, found := c.knownValues[hashValue]; found {
		return nil, true
	}

	// The resource is not in the cache, mark the resource as busy until it has
	// been cached successfully. Unlocking lock is required!
	lock := new(sync.Mutex)
	lock.Lock()
	c.busyValues[hashValue] = lock
	return lock, false
}
// Returns true if the resource is found, and false otherwise. If the
// resource is busy, this method will hang until the resource is free. If
// the resource is not found, a lock indicating that the resource is busy will
// be returned. Once the resource has been put into cache the busy lock *must*
// be unlocked to allow others to access the newly cached resource
Returns true if the resource is found, and false otherwise. If the
resource is busy, this method will hang until the resource is free. If
the resource is not found, a lock indicating that the resource is busy will
be returned. Once the resource has been put into cache the busy lock *must
be unlocked to allow others to access the newly cached resource
// Returns true if the resource is found and false otherwise . If the // resource is busy this method will hang until the resource is free . If // the resource is not found a lock indicating that the resource is busy will // be returned . Once the resource has been put into cache the busy lock * must * // be unlocked to allow others to access the newly cached resource
func (c *Cache) has(key string) (*sync.Mutex, bool) {
	hashValue := calcHash(key)
	c.mutex.Lock()
	defer c.mutex.Unlock()
	if lock, busy := c.busyValues[hashValue]; busy {
		c.mutex.Unlock()
		lock.Lock()
		lock.Unlock()
		c.mutex.Lock()
	}
	if _, found := c.knownValues[hashValue]; found {
		return nil, true
	}
	lock := new(sync.Mutex)
	lock.Lock()
	c.busyValues[hashValue] = lock
	return lock, false
}
func ( c * Cache ) has ( key string ) ( * sync . Mutex , bool ) { hashValue := calcHash ( key ) c . mutex . Lock ( ) defer c . mutex . Unlock ( ) if lock , busy := c . busyValues [ hashValue ] ; busy { c . mutex . Unlock ( ) lock . Lock ( ) lock . Unlock ( ) c . mutex . Lock ( ) } if _ , found := c . knownValues [ hashValue ] ; found { return nil , true } lock := new ( sync . Mutex ) lock . Lock ( ) c . busyValues [ hashValue ] = lock return lock , false }
Returns true if the resource is found, and false otherwise.
Returns true if the resource is found and false otherwise .
// If the resource is busy, wait for it to be free. This is the case if // the resource is currently being cached as a result of another request. // Also, release the lock on the cache to allow other readers while waiting // If a resource is in the shared cache, it can't be reserved. One can simply // access it directly from the cache // The resource is not in the cache, mark the resource as busy until it has // been cached successfully. Unlocking lock is required!