Return the value at the given time in ``cache``
4642
def _valcache_lookup(self, cache, branch, turn, tick):
        """"""
        if branch in cache:
            branc = cache[branch]
            try:
                if turn in branc and branc[turn].rev_gettable(tick):
                    return branc[turn][tick]
                elif branc.rev_gettable(turn-1):
                    turnd = branc[turn-1]
                    return turnd[turnd.end]
            except HistoryError as ex:
                # probably shouldn't ever happen, empty branches shouldn't be kept in the cache at all...
                # but it's easy to handle
                if ex.deleted:
                    raise
        for b, r, t in self.db._iter_parent_btt(branch, turn, tick):
            if b in cache:
                if r in cache[b] and cache[b][r].rev_gettable(t):
                    try:
                        return cache[b][r][t]
                    except HistoryError as ex:
                        if ex.deleted:
                            raise
                elif cache[b].rev_gettable(r-1):
                    cbr = cache[b][r-1]
                    try:
                        return cbr[cbr.end]
                    except HistoryError as ex:
                        if ex.deleted:
                            raise
950583
def get(self, key, _else=None):
        
        with self._lock:
            self.expired()
            # see if everything expired
            try:
                value = self._dict[key].get()
                return value
            except KeyError:
                return _else
            except ValueError:
                return _else
8263
def parse(value)
      unless value.is_a?(String)
        raise TimeParseError, "value must be string: #{value}"
      end

      if @cache1_key == value
        return @cache1_time
      elsif @cache2_key == value
        return @cache2_time
      else
        begin
          time = @parse.call(value)
        rescue => e
          raise TimeParseError, "invalid time format: value = #{value}, error_class = #{e.class.name}, error = #{e.message}"
        end
        @cache1_key = @cache2_key
        @cache1_time = @cache2_time
        @cache2_key = value
        @cache2_time = time
        return time
      end
    end
402652
def cached_unless_authenticated(timeout=50, key_prefix='default'):
    """"""
    def caching(f):
        @wraps(f)
        def wrapper(*args, **kwargs):
            cache_fun = current_cache.cached(
                timeout=timeout, key_prefix=key_prefix,
                unless=lambda: current_cache_ext.is_authenticated_callback())
            return cache_fun(f)(*args, **kwargs)
        return wrapper
    return caching
420547
function getCacheRefreshInterval() {
    var value = parseInt(process.env[CACHE_REFRESH_KEY]);

    // Should we 0 here to invalidate the cache immediately?
    if (value && !isNaN(value) && value > 0) {
      return value;
    }

    return DEFAULT_CACHE_REFRESH_SECONDS;
  }
287844
def pexpire_at(self, _time):
        
        return self._client.pexpireat(self.key_prefix, round(_time))
460900
def cached(function):
    """"""
    cache_variable = '_cached_' + function.__name__
    @wraps(function)
    def function_wrapper(obj, *args, **kwargs):
        # values are cached in a dict stored in the object
        try:
            cache = getattr(obj, cache_variable)
        except AttributeError:
            cache = {}
            setattr(obj, cache_variable, cache)
        args_kwargs = args + tuple(kwargs.values())
        try:
            return cache[args_kwargs]
        except KeyError:
            cache_value = function(obj, *args, **kwargs)
            cache[args_kwargs] = cache_value
            return cache_value
    return function_wrapper
124755
def _cache_get(self, date):
        
        if date in self.cache_data:
            logger.debug('Using class-cached data for date %s',
                         date.strftime('%Y-%m-%d'))
            return self.cache_data[date]
        logger.debug('Getting data from cache for date %s',
                     date.strftime('%Y-%m-%d'))
        data = self.cache.get(self.project_name, date)
        self.cache_data[date] = data
        return data
902252
def cache_key(self):
        """"""
        try:
            return self.path
        except TypeError:
            raise TypeError("self.path is invalild: '{}', '{}'".format(str(self.path), type(self.path)))
923932
def cache(key = nil)
      key ||= BasicCache.caller_name
      key = key.to_sym
      if include? key
        @store[key].value
      else
        value = yield
        @store[key] = TimeCacheItem.new Time.now, value
        value
      end
    end
435639
def ulocalized_time(self, time, context, request):
        
        value = ut(time, long_format=self.show_time, time_only=False,
                   context=context, request=request)
        return value or ""
374732
function _getCached( cached, data )
	{
		if( !data ){ return cached; }

		let i = -1, len = cached.length;
        while (++i < len) {
            cached[i].data = data;
        }
        return cached;
	}
386564
def cached(key, timeout=3600):
    

    def decorator(f):
        @wraps(f)
        def wrapped(*args, **kwargs):
            cache = get_cache()
            # Check if key is a function
            if callable(key):
                cache_key = key(*args, **kwargs)
            else:
                cache_key = key
            # Try to get the value from cache
            cached_val = cache.get(cache_key)
            if cached_val is None:
                # Call the original function and cache the result
                cached_val = f(*args, **kwargs)
                cache.set(cache_key, cached_val, timeout)
            return cached_val

        return wrapped

    return decorator
779125
def set_value(cache, key, value):
    
    with cache as redis_connection:
        return redis_connection.set(key, value)
1117510
def _get_cached_time(self):
        
        if not self._cached_time:
            self._cached_time = self._meta.datetime.utcnow()

        return self._cached_time
340507
def get_item(key):
    """"""
    CACHED_KEY_FILE = os.path.join(CURRENT_DIR, key)

    try:
        return json.loads(open(CACHED_KEY_FILE, "rb").read().decode('UTF-8'))["_"]
    except (IOError, ValueError):
        return None
599354
function(key) {

            // get value and time left
            var ret = {
                value: this._storage.getItem(key),
                timeLeft: this.getTimeLeft(key),
            };

            // set if expired
            ret.isExpired = ret.timeLeft !== null && ret.timeLeft <= 0;

            // return data
            return ret;
        }