Pre-scan the cache to see which keys are present.
556248
protected function prescan_keys() {
        $files = glob($this->glob_keys_pattern(), GLOB_MARK | GLOB_NOSORT);
        if (is_array($files)) {
            foreach ($files as $filename) {
                $this->keys[basename($filename)] = filemtime($filename);
            }
        }
    }
407182
public Set<K> checkAllPresent(final Iterable<? extends K> keys) {
    Set<K> _keysToLoad = new HashSet<K>();
    for (K k : keys) {
      Entry<K,V> e = lookupEntryNoHitRecord(k);
      if (e == null || !e.hasFreshData(clock)) {
        _keysToLoad.add(k);
      }
    }
    return _keysToLoad;
  }
1135858
private void ensureNext() {
        // Check if the current scan result has more keys (i.e. the index did not reach the end of the result list)
        if (resultIndex < scanResult.getResult().size()) {
            return;
        }
        // Since the current scan result was fully iterated,
        // if there is another cursor scan it and ensure next key (recursively)
        if (!FIRST_CURSOR.equals(scanResult.getStringCursor())) {
            scanResult = scan(scanResult.getStringCursor(), scanParams);
            resultIndex = 0;
            ensureNext();
        }
    }
635248
public boolean containsKey(Object key) {
	int k = checkKey(key);
	int index = Arrays.binarySearch(keyIndices, k);
	return index >= 0;
    }
410779
def cache_key_exist(self, key):
        """"""
        key_exist = True if cache.get(key) else False
        status = 200 if key_exist else 404
        return json_success(json.dumps({'key_exist': key_exist}),
                            status=status)
1047137
def _lookup(key):
    
    if key not in _CACHE:
        return None
    if _CACHE_COUNTER[key] >= len(_CACHE[key][1:]):
        if _CACHE[key][0] == "empty":
            return ""
        elif _CACHE[key][0] == "repeat" and _CACHE[key][1:]:
            return _CACHE[key][-1]
        elif _CACHE[key][0] == "repeat":
            return ""
        else:
            _CACHE_COUNTER[key] = 1
    else:
        _CACHE_COUNTER[key] += 1
    if _CACHE[key]:
        return _CACHE[key][_CACHE_COUNTER[key]]
    else:
        return ""
365779
def _get_cache_key(self, obj):
        """"""
        if obj is not None:
            # Make sure that key is REALLY unique.
            return '{}-{}'.format(id(self), obj.pk)

        return "{}-None".format(id(self))
1138052
function hasKey(key) {
		var reads = stacheKey.reads(key);
		var readValue;

		if (reads[0].key === "scope") {
			// read properties like `scope.vm.foo` directly from the scope
			readValue = stacheKey.read(this, reads.slice(1), key);
		} else {
			// read normal properties from the scope's context
			readValue = stacheKey.read(this._context, reads, key);
		}

		return readValue.foundLastParent && readValue.parentHasKey;
	}
225492
def has_key(self, key):
        
        if key in self._dict:
            try: 
                self[key]
                return True
            except ValueError:
                return False
            except KeyError:
                return False
        return False
990404
def has_keys(self, keys):
        
        self.is_a(Mapping)
        self.contains_all_of(keys)
        return ChainInspector(self._subject)
1078660
def has_key?(key, opts={})
      key = normalize_key(key) if opts.fetch(:normalize, true)
      @source.has_key?(key)
    end
584103
private void preloadCaches() throws IOException, XmlException {
        Map<String,Properties> caches = getPreloadCacheSpecs();
        for (String cacheName : caches.keySet()) {
            Properties cacheProps = caches.get(cacheName);
            String cacheClassName = cacheProps.getProperty("ClassName");
            logger.info(" - loading cache " + cacheName);
            CacheService cachingObj = getCacheInstance(cacheClassName, cacheProps);
            if (cachingObj != null) {
                long before = System.currentTimeMillis();
                if (cachingObj instanceof PreloadableCache) {
                    ((PreloadableCache)cachingObj).loadCache();
                }
                synchronized(allCaches) {
                    allCaches.put(cacheName, cachingObj);
                }
                logger.debug("    - " + cacheName + " loaded in " + (System.currentTimeMillis() - before) + " ms");
            }
            else {
                logger.warn("Caching Class is  invalid. Name-->"+cacheClassName);
            }
        }
    }
617506
public function hasKey()
    {
        $this->failIf(!array_key_exists($this->data[1], $this->data[0]));

        return $this->data[0][$this->data[1]];
    }
438136
def find_in_cache(cacheKey):
    """"""
    # If we have to use cache, we try to find the result in cache
    if cacheKey:

        data = cache.get('plugit-cache-' + cacheKey, None)

        # We found a result, we can return it
        if data:
            return (data['result'], data['menu'], data['context'])
    return (None, None, None)
456671
def key_exists(self, key, secret=False):
        '''
        
        '''
        if len(key) < 8:
            return False
        key = key.upper()
        res = self.list_keys(secret)
        for fingerprint in res.keys:
            if fingerprint.endswith(key):
                return True
        return False
1102740
def keys(self):
        """"""

        keys = OrderedDict()

        def order_key(_):
            (k, v) = _
            cache_key = getattr(type(self), k)
            return cache_key.order

        items = [(k, getattr(type(self), k)) for k
            in dir(type(self))
        ]
        items = [(k, v) for (k, v)
            in items
            if isinstance(v, Key)
        ]

        for k, v in sorted(items, key=order_key):
            keys[k] = getattr(self, k)
        return keys
1063181
private function getCachedKeys()
    {
        $key = 'courier_cached_requests';

        if ($this->cache->isExisting($key))
        {
            return $this->cache->get($key);
        }

        $newIndex = [];
        $this->cache->set($key, $newIndex);

        return $newIndex;
    }