code: func NewCachedDiscoveryClientForConfig(config *restclient.Config, discoveryCacheDir, httpCacheDir string, ttl time.Duration) (*CachedDiscoveryClient, error) {
  	if len(httpCacheDir) > 0 {
  		// update the given restconfig with a custom roundtripper that
  		// understands how to handle cache responses.
  		config = restclient.CopyConfig(config)
  		config.Wrap(func(rt http.RoundTripper) http.RoundTripper {
  			return newCacheRoundTripper(httpCacheDir, rt)
  		})
  	}
  
  	discoveryClient, err := discovery.NewDiscoveryClientForConfig(config)
  	if err != nil {
  		return nil, err
  	}
  
  	return newCachedDiscoveryClient(discoveryClient, discoveryCacheDir, ttl), nil
  }
docs: // NewCachedDiscoveryClientForConfig creates a new DiscoveryClient for the given config, and wraps
  // the created client in a CachedDiscoveryClient. The provided configuration is updated with a
  // custom transport that understands cache responses.
  // We receive two distinct cache directories for now, in order to preserve old behavior
  // which makes use of the --cache-dir flag value for storing cache data from the CacheRoundTripper,
  // and makes use of the hardcoded destination (~/.kube/cache/discovery/...) for storing
  // CachedDiscoveryClient cache data. If httpCacheDir is empty, the restconfig's transport will not
  // be updated with a roundtripper that understands cache responses.
  // If discoveryCacheDir is empty, cached server resource data will be looked up in the current directory.
  // TODO(juanvallejo): the value of "--cache-dir" should be honored. Consolidate discoveryCacheDir with httpCacheDir
  // so that server resources and http-cache data are stored in the same location, provided via config flags.