Return an instance of a element as a ElementCache dict
    used as a cache.
    
    :rtype ElementCache
511978
def LoadElement(href, only_etag=False):
    
    request = SMCRequest(href=href)
    request.exception = FetchElementFailed
    result = request.read()
    if only_etag:
        return result.etag
    return ElementCache(
        result.json, etag=result.etag)
288764
private final synchronized CacheElement getCacheElement(String userid) {
        String m = getCacheAbbrev() + " getCacheElement() ";
        CacheElement cacheElement = null;
        String key = getKey(userid);
        logger.debug(m + "key==" + key);
        if (cache.containsKey(key)) {
            logger.debug(m + "cache already has element");
        } else {
            logger.debug(m + "cache does not have element; create and put");
            CacheElement itemtemp =
                    new CacheElement(userid, getCacheId(), getCacheAbbrev());
            cache.put(key, itemtemp);
        }
        cacheElement = (CacheElement) cache.get(key);
        if (cacheElement == null) {
            logger.error(m + "cache does not contain element");
        } else {
            logger.debug(m + "element retrieved from cache successfully");
        }
        return cacheElement;
    }
367238
def cached(func, instance, args, kwargs):
    """"""
    cache = getattr(instance, "__cache", None)
    if cache is None:
        instance.__cache = cache = {}
    try:
        return cache[func]
    except KeyError:
        cache[func] = result = func(*args, **kwargs)
        return result
1019715
def _loadcache(cachefile):
    
    cache = {}
    if os.path.exists(cachefile):
        with open(cachefile) as f:
            for line in f:
                line = line.split()
                if len(line) == 2:
                    try:
                        cache[int(line[0])] = float(line[1])
                    except:
                        pass
    return cache
1342537
def to_a
      hash = {}
      @to_a ||=
        elements_with_tags.map.with_index do |(el, tag_name), idx|
          selector = @selector.dup
          selector[:index] = idx unless idx.zero?
          element = element_class.new(@query_scope, selector)
          if [HTMLElement, Input].include? element.class
            construct_subtype(element, hash, tag_name).tap { |e| e.cache = el }
          else
            element.tap { |e| e.cache = el }
          end
        end
    end
1336012
def _get_cache(self):
        
        if not self._cache:
            self._cache = get_cache(self.app)
        return self._cache
493859
def memoize(f):
    
    cache = {}

    @wraps(f)
    def inner(arg):
        if arg not in cache:
            cache[arg] = f(arg)
        return cache[arg]
    return inner
971727
def get(self, key):
        
        o = self.data[key]()
        if o is None:
            # On CPython, the weakref callback will always(?) run before any
            # other code has a chance to observe that the weakref is broken;
            # and since the callback removes the item from the dict, this
            # branch of code should never run. However, on PyPy (and possibly
            # other Python implementations), the weakref callback does not run
            # immediately, thus we may be able to observe this intermediate
            # state. Should this occur, we remove the dict item ourselves,
            # and raise CacheFault (which is a KeyError subclass).
            del self.data[key]
            raise CacheFault(
                "FinalizingCache has %r but its value is no more." % (key,))
        log.msg(interface=iaxiom.IStatEvent, stat_cache_hits=1, key=key)
        return o
1306268
def get_cache(self, request):
        

        # try and get the cached GET response
        cache_key = self.cache_key(request)
        cached_response = cache.get(cache_key, None)
        # if it wasn't found and we are looking for a HEAD, try looking for a corresponding GET
        if cached_response is None and request.method == 'HEAD':
            cache_key = self.cache_key(request, 'GET')
            cached_response = cache.get(cache_key, None)
        if cached_response is None:
            return None, None
        if cached_response[1] < time.time() - settings.BETTERCACHE_LOCAL_POSTCHECK:
            return cached_response[0], True
        return cached_response[0], False
786181
public static ClassDescriptorCache getInstance() {
    if (INSTANCE == null) {
      synchronized (ClassDescriptorCache.class) {
        if (INSTANCE == null) {
          INSTANCE = new ClassDescriptorCache();
        }
      }
    }
    return INSTANCE;
  }
52984
public Element getWithData(Ehcache cache, Object key, A data) {
        this.threadData.set(data);
        try {
            return cache.get(key);
        } finally {
            this.threadData.remove();
        }
    }
1046031
def cache_key(self):
        
        return '%s:%s' % (super(EntryPublishedVectorBuilder, self).cache_key,
                          Site.objects.get_current().pk)
896003
def all(self, cache=False):
        
        if cache:
            return [get_object(self.modelb, obj_id, cache=True, use_local=True) for obj_id in self.keys(True)]
        else:
            return self
632383
def update_cache_key(cls, cache_key, item=None):
        
        contents = cls.__thread_id_cache.get(cache_key, None)
        if item is not None:
            cls.__thread_id_cache[cache_key] = item

        return contents
193388
def cached_property(prop):
    
    def cache_wrapper(self):
        if not hasattr(self, "_cache"):
            self._cache = {}
        if prop.__name__ not in self._cache:
            return_value = prop(self)
            if isgenerator(return_value):
                return_value = tuple(return_value)
            self._cache[prop.__name__] = return_value
        return self._cache[prop.__name__]
    return property(cache_wrapper)
831316
def memoize(fn):
    
    cache = {}

    @wraps(fn)
    def wrapped_fn(*args, **kwargs):
        cache_key = _memoize_cache_key(args, kwargs)
        try:
            return cache[cache_key]
        except KeyError:
            value = fn(*args, **kwargs)
            cache[cache_key] = value
            return value

    def clear_cache():
        cache.clear()

    # Needed to ensure that EnsemblRelease.clear_cache
    # is able to clear memoized values from each of its methods
    wrapped_fn.clear_cache = clear_cache
    # expose the cache so we can check if an item has already been computed
    wrapped_fn.cache = cache
    # if we want to check whether an item is in the cache, first need
    # to construct the same cache key as used by wrapped_fn
    wrapped_fn.make_cache_key = _memoize_cache_key
    return wrapped_fn
1161061
def get(self, index):
        
        if self and (index <= len(self) -1):
            return self._result_cache[index]