func (c *Cache) Get(request *dns.Msg) (*dns.Msg, bool) {
	if request == nil {
		return nil, false
	}
	// create key for request
	ok, key := key(request)
	if !ok {
		log.Printf("key returned !ok")
		return nil, false
	}
	c.Lock()
	if c.items == nil {
		c.Unlock()
		return nil, false
	}
	c.Unlock()
	rawValue, err := c.items.Get(key)
	if err == gcache.KeyNotFoundError {
		// not a real error, just no key found
		return nil, false
	}

	if err != nil {
		// real error
		log.Printf("can't get response for %s from cache: %s", request.Question[0].Name, err)
		return nil, false
	}

	cachedValue, ok := rawValue.(item)
	if !ok {
		log.Printf("entry with invalid type in cache for %s", request.Question[0].Name)
		return nil, false
	}

	response := cachedValue.fromItem(request)
	return response, true
}
// Get returns the dns response for the provided request if found
Get returns the dns response for the provided request if found
// Get returns the dns response for the provided request if found
func (c *Cache) Get(request *dns.Msg) (*dns.Msg, bool) {
	if request == nil {
		return nil, false
	}
	ok, key := key(request)
	if !ok {
		log.Printf("key returned !ok")
		return nil, false
	}
	c.Lock()
	if c.items == nil {
		c.Unlock()
		return nil, false
	}
	c.Unlock()
	rawValue, err := c.items.Get(key)
	if err == gcache.KeyNotFoundError {
		return nil, false
	}
	if err != nil {
		log.Printf("can't get response for %s from cache: %s", request.Question[0].Name, err)
		return nil, false
	}
	cachedValue, ok := rawValue.(item)
	if !ok {
		log.Printf("entry with invalid type in cache for %s", request.Question[0].Name)
		return nil, false
	}
	response := cachedValue.fromItem(request)
	return response, true
}
func ( c * Cache ) Get ( request * dns . Msg ) ( * dns . Msg , bool ) { if request == nil { return nil , false } ok , key := key ( request ) if ! ok { log . Printf ( " " ) return nil , false } c . Lock ( ) if c . items == nil { c . Unlock ( ) return nil , false } c . Unlock ( ) rawValue , err := c . items . Get ( key ) if err == gcache . KeyNotFoundError { return nil , false } if err != nil { log . Printf ( " " , request . Question [ 0 ] . Name , err ) return nil , false } cachedValue , ok := rawValue . ( item ) if ! ok { log . Printf ( " " , request . Question [ 0 ] . Name ) return nil , false } response := cachedValue . fromItem ( request ) return response , true }
Get returns the dns response for the provided request if found
Get returns the dns response for the provided request if found
// create key for request // not a real error, just no key found // real error