Check and return a value from the cache.

Returns false if there is no entry.
188877
public static function check($cacheloc, $cachekey)
    {
        $cacheloc = "cache_" . $cacheloc;
        if ( isset($_SESSION[$cacheloc]) ) {
            $cache_row = $_SESSION[$cacheloc];
            if ( time() >= $cache_row[2] ) { 
                unset($_SESSION[$cacheloc]);
                return false;
            }
            if ( $cache_row[0] == $cachekey ) {
                // error_log("Cache hit $cacheloc");
                return $cache_row[1];
            }
            unset($_SESSION[$cacheloc]);
        }
        return false;
    }
1358853
def check_cache(self, type, data, obj=None):
        ''''''
        try:
            id = data['id']
        except:
            # Not an identifiable item
            #print 'don\'t know this item %r:%r' % (type, data)
            return data

        # If obj was passed in, its type takes precedence
        try:
            type = obj._get_type()
        except:
            pass

        # Find the item in the cache, update and return if it's there
        try:
            hit = self.item_cache[type][id]
        except KeyError:
            pass
        else:
            hit._update_data(data)
            #print 'cache hit for %s at %s' % (type, id)
            return hit

        # Not there? Let's make us a new item
        # If we weren't given the object ref, find the name in the global scope
        if not obj:
            # Default to Redmine_Item if it's not found
            obj = self.item_class.get(type, Redmine_Item)

        new_item = obj(redmine=self, data=data, type=type)

        # Store it
        self.item_cache.setdefault(type, {})[id] = new_item
        #print 'set new %s at %s' % (type, id)

        return new_item
1104109
def key?(key)
      # First, check if item is already cached in memory
      return true if @cache.key?(key)
      # Otherwise, it might be cached on disk
      # but we should not consider the disk cache if it is disabled
      return false unless disk_cache_enabled?

      path = path_to(hash(key))
      File.file?(path) && File.readable?(path)
    end
319064
def exists(self, key, fresh=False):
        
        key = key.upper()
        if key in self._deleted:
            return False
        return self.get(key, fresh=fresh, default=missing) is not missing
914861
def get(self, key):
        

        if not key in self._actions:
            return None
        if not key in self._cache:
            self._cache[key] = self._actions[key]()

        return self._cache[key]
639388
def verify(self):
        
        # if we are in a lock don't check anything
        if self._lock != 0:
            return

        # check the hash of our data
        id_new = self._id_function()

        # things changed
        if id_new != self.id_current:
            if len(self.cache) > 0:
                log.debug('%d items cleared from cache: %s',
                          len(self.cache),
                          str(list(self.cache.keys())))
            # hash changed, so dump the cache
            # do it manually rather than calling clear()
            # as we are internal logic and can avoid function calls
            self.cache = {}
            # set the id to the new data hash
            self.id_current = id_new
483924
def get_default_value(self, check):
        
        fun_name, fun_args, fun_kwargs, default = self._parse_with_caching(check)
        if default is None:
            raise KeyError('Check "%s" has no default value.' % check)
        value = self._handle_none(default)
        if value is None:
            return value
        return self._check_value(value, fun_name, fun_args, fun_kwargs)
390493
public V get(K key)
  {
    Entry<V> entry = _cache.get(key);

    if (entry == null)
      return null;

    if (entry.isValid())
      return entry.getValue();
    else {
      _cache.remove(key);

      return null;
    }
  }
1247567
def check(self, value):
        
        if self._inclusive:
            return False if self._min <= value <= self._max else True
        else:
            return False if value > self._max or value < self._min else True
602090
def _get_from_cache(self, expr):
        """"""
        is_cached, res = super()._get_from_cache(expr)
        if is_cached:
            indent_str = "    " * self._print_level
            return True, indent(res, indent_str)
        else:
            return False,  None
555858
private V returnValue(K key, V _value) {
    if (_value != null) {
      Duration d = expiryPolicy.getExpiryForAccess();
      if (d != null) {
        c2kCache.expireAt(key, calculateExpiry(d));
      }
      return _value;
    }
    return null;
  }
452214
def check(self):
    

    if self.value is None:
      return False
    return (time.clock() - self.start) >= self.value
1196915
private CacheEntry getCacheEntry(Object value, boolean create)
  {

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.entry(
        this,cclass,
        "getCacheEntry",
        new Object[] { value, new Boolean(create), matchCache });

    CacheEntry e = (CacheEntry) matchCache.get(value);
    if (e == null)
    {
      if (create)
      {
        e = new CacheEntry();
        // The following method call may stimulate multiple callbacks to the shouldRetain
        // method if the Hashtable is at the rehash threshold.
        matchCache.put(value, e);
        cacheCreates++;
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.exit(this,cclass, "getCacheEntry", e);

    return e;
  }
537237
def has_item(self, url):
        

        _hash = self.build_hash(url)
        self.execute('BEGIN')
        self.execute('''
            SELECT id
            FROM cache
            WHERE id = x%s
            LIMIT 1
        ''', (_hash,))
        row = self.cursor.fetchone()
        self.execute('COMMIT')
        return True if row else False
870387
def entryCheck(self, event = None, repair = True):
        
        valupr = self.choice.get().upper()
        if valupr.strip() == 'INDEF':
            self.choice.set(valupr)
        return EparOption.entryCheck(self, event, repair = repair)
949983
def lookup(self, fact, cache=True):
        """"""
        if (not cache) or (not self.has_cache()):
            val =  self.run_facter(fact)
            if val is None or val == '':
                raise KeyError(fact)
            return val
        return self._cache[fact]
57802
static protected function check()
    {
        empty(self::$cachepath) && self::$cachepath = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Cache' . DIRECTORY_SEPARATOR;
        self::$cachepath = rtrim(self::$cachepath, '/\\') . DIRECTORY_SEPARATOR;
        if (!is_dir(self::$cachepath) && !mkdir(self::$cachepath, 0755, true)) {
            return false;
        }
        return true;
    }