code: func (ic *ImageCache) GetCache(parentID string, cfg *containertypes.Config) (string, error) {
  	imgID, err := ic.localImageCache.GetCache(parentID, cfg)
  	if err != nil {
  		return "", err
  	}
  	if imgID != "" {
  		for _, s := range ic.sources {
  			if ic.isParent(s.ID(), image.ID(imgID)) {
  				return imgID, nil
  			}
  		}
  	}
  
  	var parent *image.Image
  	lenHistory := 0
  	if parentID != "" {
  		parent, err = ic.store.Get(image.ID(parentID))
  		if err != nil {
  			return "", errors.Wrapf(err, "unable to find image %v", parentID)
  		}
  		lenHistory = len(parent.History)
  	}
  
  	for _, target := range ic.sources {
  		if !isValidParent(target, parent) || !isValidConfig(cfg, target.History[lenHistory]) {
  			continue
  		}
  
  		if len(target.History)-1 == lenHistory { // last
  			if parent != nil {
  				if err := ic.store.SetParent(target.ID(), parent.ID()); err != nil {
  					return "", errors.Wrapf(err, "failed to set parent for %v to %v", target.ID(), parent.ID())
  				}
  			}
  			return target.ID().String(), nil
  		}
  
  		imgID, err := ic.restoreCachedImage(parent, target, cfg)
  		if err != nil {
  			return "", errors.Wrapf(err, "failed to restore cached image from %q to %v", parentID, target.ID())
  		}
  
  		ic.sources = []*image.Image{target} // avoid jumping to different target, tuned for safety atm
  		return imgID.String(), nil
  	}
  
  	return "", nil
  }
docs: // GetCache returns the image id found in the cache