Generates a cache key for the icon lookup

    Includes the virtual URL to handle multiple HTTP/HTTPS domains
    Example: http://senaite.local/clients?modified=1512033263370
422579
def icon_cache_key(method, self, brain_or_object):
    
    url = api.get_url(brain_or_object)
    modified = api.get_modification_date(brain_or_object).millis()
    key = "{}?modified={}".format(url, modified)
    logger.debug("Generated Cache Key: {}".format(key))
    return key
1002005
function Favicon_onRequest(api) {

        var maxAge = 60 * 60 * 24 * 30 * 12; // one year

        api.addHeader('Content-Type', 'image/x-icon');
        api.addHeader('Cache-Control',  'public, max-age=' + ~~(maxAge));
        api.addHeader('ETag', etag(this.file));

        if (api.getMethod() !== 'GET') {
            throw new error.HttpError(500, {}, 'Favicon is accessible only via GET request');
        } else if (api.isHeaderCacheUnModified()) {
            api.sendNoChange();
        }

        return this.file;
    }
837817
def _GetUrl(self, url_id, cache, database):
    
    url_cache_results = cache.GetResults('url')
    if not url_cache_results:
      result_set = database.Query(self.URL_CACHE_QUERY)

      cache.CacheQueryResults(
          result_set, 'url', 'id', ('url', 'rev_host'))
      url_cache_results = cache.GetResults('url')

    url, reverse_host = url_cache_results.get(url_id, ['', ''])

    if not url:
      return ''

    hostname = self._ReverseHostname(reverse_host)
    return '{0:s} ({1:s})'.format(url, hostname)
1205897
def cache_page(key_params, timeout='default'):
    
    def decorator_fn(fn):
        d = CachePageDecorator()
        return d.decorate(key_params, timeout, fn)

    return decorator_fn
1129461
def store_image(self, http_client, link_hash, src, config):
        
        # check for a cache hit already on disk
        image = self.read_localfile(link_hash, src, config)
        if image:
            return image

        # no cache found download the image
        data = self.fetch(http_client, src)
        if data:
            image = self.write_localfile(data, link_hash, src, config)
            if image:
                return image

        return None
230576
def cache_key(model, pk):
    ""
    app = model._meta.app_label
    name = model._meta.module_name
    return 'api:{0}:{1}:{2}'.format(app, name, pk)
53284
function getCacheByHref(cacheManager, href) {

  var region = null;

  //href is almost never null, but it is in the case of an AuthenticationResult (at the moment), so check for existence:
  //see: https://github.com/stormpath/stormpath-sdk-node/issues/11
  if (href) {
    region = href.match(/customData/) ? 'customData' : (href.split('/').slice(-2)[0]);
  }

  if (!region || CACHE_REGIONS.indexOf(region) === -1) {
    return disabledCache;
  }

  return cacheManager.getCache(region) || new DisabledCache();
}
220044
def cached(key, path_info, details, locals)
      name, prefix, partial = path_info

      if key
        @cache.cache(key, name, prefix, partial, locals) do
          yield
        end
      else
        yield
      end
    end
220331
def get_cache_key(request, page, lang, site_id, title):
    
    from cms.cache import _get_cache_key
    from cms.templatetags.cms_tags import _get_page_by_untyped_arg

    from cms.models import Page
    if not isinstance(page, Page):
        page = _get_page_by_untyped_arg(page, request, site_id)
    if not site_id:
        try:
            site_id = page.node.site_id
        except AttributeError:  # CMS_3_4
            site_id = page.site_id
    if not title:
        return _get_cache_key('page_tags', page, '', site_id) + '_type:tags_list'
    else:
        return _get_cache_key('title_tags', page, lang, site_id) + '_type:tags_list'
72772
def _GetUrl(self, url, cache, database):
    
    if not url:
      return ''

    url_cache_results = cache.GetResults('url')
    if not url_cache_results:
      result_set = database.Query(self._URL_CACHE_QUERY)

      cache.CacheQueryResults(result_set, 'url', 'id', ('url', 'title'))
      url_cache_results = cache.GetResults('url')

    reference_url, reference_title = url_cache_results.get(url, ['', ''])

    if not reference_url:
      return ''

    return '{0:s} ({1:s})'.format(reference_url, reference_title)
264719
public ImageIcon retrieveIcon(URL location) throws IconProviderException
	{
		if (!getCache().containsKey(location))
		{
			getCache().put(location, new ImageIcon(location));
		}
		return getCache().get(location);
	}
498958
@Override
    public final CacheKey getCacheKey(HttpServletRequest request, HttpServletResponse response) {
        final Resource stylesheetResource = this.getStylesheetResource(request);
        final Serializable stylesheetCacheKey;
        try {
            stylesheetCacheKey = this.xmlUtilities.getStylesheetCacheKey(stylesheetResource);
        } catch (TransformerConfigurationException e) {
            throw new RuntimeException(
                    "Failed to get Transformer for stylesheet: " + stylesheetResource, e);
        } catch (IOException e) {
            throw new RuntimeException("Failed to load stylesheet: " + stylesheetResource, e);
        }

        return CacheKey.build(stylesheetResource.getDescription(), stylesheetCacheKey);
    }
132197
function _request_creator(mod_opts) {
	mod_opts = mod_opts || {};

	var _path = mod_opts.path || '';
	var _id = 0;
	var _cache = {};

	/** */
	function _cache_has_id(id) {
		return Object.prototype.hasOwnProperty.call(_cache, id) ? true : false;
	}

	/** */
	function _cache_cleanup(id) {
		if(_cache_has_id(id)) {
			delete _cache[id];
		}
	}
	
	/** HTTP request runner */
	function request_handler(req, res) {
		var server_start_time = get_time();
		var cache, url, id;
		
		url = require('url').parse(req.url, true);
		
		if(url.pathname === _path + '/time') {
			_id = Math.floor(Math.random()*100000000000000000);
			cache = {'id':_id, 'start': server_start_time, 'end':undefined};
			_cache[_id] = cache;
			
			req.on('close', _cache_cleanup.bind(undefined, _id) );
			
			req.on('end', function() {
				cache.status = true;
				cache.end = get_time();
			});
			
			setTimeout(_cache_cleanup.bind(undefined, _id), 1000*30);
		
			res.writeHead(200, {'Content-Type': 'application/json'});
			res.end(JSON.stringify(_id));
		} else if(url.pathname.substr(0, _path.length + 6) === _path + '/fetch') {
			id = parseInt(url.query.id, 10);
			if(_cache_has_id(id)) {
				res.writeHead(200, {'Content-Type': 'application/json'});
	
				res.end(JSON.stringify(_cache[id]));
				_cache_cleanup(id);
			} else {
				res.writeHead(404, {'Content-Type': 'application/json'});
				res.end(JSON.stringify("404 - Not Found"));
			}
		} else {
			res.writeHead(404, {'Content-Type': 'application/json'});
			res.end(JSON.stringify("404 - Not Found"));
		}
	}

	return request_handler;
}
1104539
def url2domain(url):
    
    parsed_uri = urlparse.urlparse(url)
    domain = '{uri.netloc}'.format(uri=parsed_uri)
    domain = re.sub("^.+@", "", domain)
    domain = re.sub(":.+$", "", domain)
    return domain
619652
def cache_url(self, var=DEFAULT_CACHE_ENV, default=NOTSET, backend=None):
        
        return self.cache_url_config(self.url(var, default=default), backend=backend)
891834
function cachepath(location) {
    var uri = url.parse(location);
    if (!uri.protocol) {
        throw new Error('Invalid URL: ' + location);
    } else {
        var hash = crypto.createHash('md5')
            .update(location)
            .digest('hex')
            .substr(0,8) +
            '-' + path.basename(uri.pathname, path.extname(uri.pathname));
        var extname = path.extname(uri.pathname);
        return _(['.shp', '.zip', '']).include(extname.toLowerCase()) ?
            path.join(hash, hash + extname)
            : path.join(hash + extname);
    }
}
473021
def _get(self, url,
             param_dict=None,
             securityHandler=None,
             additional_headers=None,
             handlers=None,
             proxy_url=None,
             proxy_port=None,
             compress=True,
             custom_handlers=None,
             out_folder=None,
             file_name=None):
        
        # ensure that no spaces are in the url
        url = url.replace(" ", "%20")

        pass_headers = {}
        if custom_handlers is None:
            custom_handlers = []
        if handlers is None:
            handlers = []
        if param_dict is None:
            param_dict = {}
        self._last_method = "GET"
        CHUNK = 4056
        param_dict, handler, cj = self._processHandler(securityHandler, param_dict)
        if additional_headers is not None:
            headers = [] + additional_headers
        else:
            headers = []
        pass_headers = {}
        if securityHandler and securityHandler.referer_url:
            pass_headers['referer'] = securityHandler.referer_url
        for h in headers:
            pass_headers[h[0]] = h[1]

        if compress:
            pass_headers['Accept-encoding'] = 'gzip'
        else:
            pass_headers['Accept-encoding'] = ""
        #headers.append(('User-Agent', USER_AGENT))
        pass_headers['User-Agent'] = self.useragent
        if len(param_dict.keys()) == 0:
            param_dict = None
        if handlers is None:
            handlers = []
        if handler is not None:
            handlers.append(handler)
        handlers.append(RedirectHandler())
        if self._verify == False and \
           sys.version_info[0:3] >= (2, 7, 9) and \
            hasattr(ssl,'create_default_context'):
            ctx = ssl.create_default_context()
            ctx.check_hostname = False
            ctx.verify_mode = ssl.CERT_NONE
            handlers.append(request.HTTPSHandler(context=ctx))
        if cj is not None:
            handlers.append(request.HTTPCookieProcessor(cj))
        if proxy_url is not None:
            if proxy_port is None:
                proxy_port = 80
            proxies = {"http":"http://%s:%s" % (proxy_url, proxy_port),
                       "https":"https://%s:%s" % (proxy_url, proxy_port)}
            proxy_support = request.ProxyHandler(proxies)
            handlers.append(proxy_support)
        opener = request.build_opener(*handlers)

        opener.addheaders = headers
        request.install_opener(opener)
        ctx = None
        hasContext = False
        if self._verify == False and \
           'context' in self._has_context(request.urlopen) and \
            sys.version_info[0:3] >= (2, 7, 9) and \
            hasattr(ssl,'create_default_context'):
            ctx = ssl.create_default_context()
            ctx.check_hostname = False
            ctx.verify_mode = ssl.CERT_NONE
            hasContext = True

        if hasContext == False:

            if param_dict is None:
                req = request.Request(self._asString(url),
                                      headers=pass_headers)
                resp = request.urlopen(req)
            elif len(str(urlencode(param_dict))) + len(url) >= 1999:
                return self._post(
                    url=url,
                    param_dict=param_dict,
                    files=None,
                    securityHandler=securityHandler,
                    additional_headers=additional_headers,
                    custom_handlers=custom_handlers,
                    proxy_url=proxy_url,
                    proxy_port=proxy_port,
                    compress=compress,
                    out_folder=out_folder,
                    file_name=file_name,
                    force_form_post=False)
            else:
                format_url = self._asString(url) + "?%s" % urlencode(param_dict)
                req = request.Request(format_url,
                                      headers=pass_headers)
                resp = request.urlopen(req)
        else:
            if param_dict is None:
                req = request.Request(self._asString(url),
                                      headers=pass_headers)
                resp = request.urlopen(req,
                                       context=ctx)
            elif len(str(urlencode(param_dict))) + len(url) >= 1999:
                return self._post(
                    url=url,
                    param_dict=param_dict,
                    files=None,
                    securityHandler=securityHandler,
                    additional_headers=additional_headers,
                    custom_handlers=custom_handlers,
                    proxy_url=proxy_url,
                    proxy_port=proxy_port,
                    compress=compress,
                    out_folder=out_folder,
                    file_name=file_name,
                    force_form_post=False)
            else:
                format_url = self._asString(url) + "?%s" % urlencode(param_dict)
                req = request.Request(format_url,
                                      headers=pass_headers)
                resp = request.urlopen(req,
                                       context=ctx)
        self._last_code = resp.getcode()
        self._last_url = resp.geturl()
        #  Get some headers from the response
        maintype = self._mainType(resp)
        contentDisposition = resp.headers.get('content-disposition')
        contentMD5 = resp.headers.get('Content-MD5')
        #contentEncoding = resp.headers.get('content-encoding')
        contentType = resp.headers.get('content-Type').split(';')[0].lower()
        contentLength = resp.headers.get('content-length')
        if maintype.lower() in ('image',
                                'application/x-zip-compressed') or \
           contentType in ('application/x-zip-compressed', 'application/octet-stream') or \
           contentMD5 is not None or\
           (contentDisposition is not None and \
            contentDisposition.lower().find('attachment;') > -1):

            fname = self._get_file_name(
                contentDisposition=contentDisposition,
                url=url)
            if out_folder is None:
                out_folder = tempfile.gettempdir()
            if contentLength is not None:
                max_length = int(contentLength)
                if max_length < CHUNK:
                    CHUNK = max_length
            file_name = os.path.join(out_folder, fname)
            with open(file_name, 'wb') as writer:
                for data in self._chunk(response=resp,
                                        size=CHUNK):
                    writer.write(data)
                    writer.flush()
                writer.flush()
                del writer
            return file_name
        else:
            read = ""
            for data in self._chunk(response=resp,
                                    size=CHUNK):
                if self.PY3 == True:
                    read += data.decode('utf-8')
                else:
                    read += data

                del data
            try:
                results = json.loads(read)
                if 'error' in results:
                    if 'message' in results['error']:
                        if results['error']['message'] == 'Request not made over ssl':
                            if url.startswith('http://'):
                                url = url.replace('http://', 'https://')
                                return self._get(url,
                                                 param_dict,
                                                 securityHandler,
                                                 additional_headers,
                                                 handlers,
                                                 proxy_url,
                                                 proxy_port,
                                                 compress,
                                                 custom_handlers,
                                                 out_folder,
                                                 file_name)
                return results
            except:
                return read