Clear cache of results which have timed out
544353
def collect(self):
        """"""
        for func in self._caches:
            cache = {}
            for key in self._caches[func]:
                if (time.time() - self._caches[func][key][1]) < self._timeouts[func]:
                    cache[key] = self._caches[func][key]
            self._caches[func] = cache
604044
def cleanup(self):
        """"""
        self.num_puts = 0
        cached = []
        for i, url_data in enumerate(self.queue):
            key = url_data.cache_url
            cache = url_data.aggregate.result_cache
            if cache.has_result(key):
                cached.append(i)
        for pos in cached:
            self._move_to_top(pos)
734780
function clearCache() {
  cache_stopById.clear();
  cache_stopByName.clear();
  cache_stopByStatusId.clear();
  cache_stops.clear();
  cache_stopsByRoute.clear();
}
1012233
def clear(self):
        
        with self._conn:
            self._conn.execute('DELETE FROM results')
            self._conn.execute('DELETE FROM work_items')
399537
def clear(self):
        """"""
        io_loop = IOLoop.current()
        while self._tombstones:
            _, req_timeout = self._tombstones.popitem()
            io_loop.remove_timeout(req_timeout)
1065847
def cache_result(cache_key, timeout):
    """"""
    def decorator(f):
        cache_name = settings.WAFER_CACHE

        @functools.wraps(f)
        def wrapper(*args, **kw):
            cache = caches[cache_name]
            result = cache.get(cache_key)
            if result is None:
                result = f(*args, **kw)
                cache.set(cache_key, result, timeout)
            return result

        def invalidate():
            cache = caches[cache_name]
            cache.delete(cache_key)

        wrapper.invalidate = invalidate
        return wrapper
    return decorator
119541
def cleanup(self, timeout):
        '''
        
        '''
        cutoff = time() - timeout
        self.collection.remove({_atime: {'$lt': cutoff}})
617153
public void clear() {
    ArrayList<Entry<K, V>> oldExclusives;
    ArrayList<Entry<K, V>> oldEntries;
    synchronized (this) {
      oldExclusives = mExclusiveEntries.clear();
      oldEntries = mCachedEntries.clear();
      makeOrphans(oldEntries);
    }
    maybeClose(oldEntries);
    maybeNotifyExclusiveEntryRemoval(oldExclusives);
    maybeUpdateCacheParams();
  }
764944
protected function clearExpired()
    {
        if (empty($this->cache)) {
            $file = $this->directory . 'Cache.dat';

            //~ Retrieve Cache information.
            if (file_exists($file)) {
                $content = file_get_contents($file);
                if (!empty($content)) {
                    $this->cache = unserialize($content);
                } else {
                    $this->cache = array();
                }
            }
        }

        // Clean all caches have expired.
        foreach ($this->cache as $pKey => $time) {
            if ($time < time()) {
                $this->remove($pKey);
            }
        }

        return true;
    }
299072
function writeCache(result) {
          result = memo[hash] = resolve(result);
          if (expire) {
            // cancel previous timer
            if (timers[hash]) clearTimeout(timers[hash]);
            // add new timer
            timers[hash] = setTimeout(clearCache, expire);
          }
          return result;
        }
910363
function onDelete(results) {
            const response = results ? results[0] : {};
            response.key = key;

            /**
             * If we passed a DataLoader instance, we clear its cache
             */
            if (options.dataloader) {
                options.dataloader.clear(key);
            }

            if (typeof response.indexUpdates !== 'undefined') {
                response.success = response.indexUpdates > 0;
            }

            /**
             * Make sure to delete the cache for this key
             */
            if (_this.__hasCache(options)) {
                return _this.clearCache(key, options.clearQueries)
                    .then(() => response)
                    .catch((err) => {
                        let msg = 'Error while clearing the cache after deleting the entity.';
                        msg += 'The entity has been deleted successfully though. ';
                        msg += 'The cache error has been attached.';
                        const cacheError = new Error(msg);
                        cacheError.__response = response;
                        cacheError.__cacheError = err;
                        throw cacheError;
                    });
            }

            return response;
        }
965453
def flush_cache(self):
        '''
        
        '''
        logger.debug('Flushing cache {}'.format(self.db_path))
        with self.db:
            for rec in self._tups:
                self.db.execute("replace into history(agent_id, t_step, key, value) values (?, ?, ?, ?)", (rec.agent_id, rec.t_step, rec.key, rec.value))
        self._tups = list()
523579
public void clearCache() {
        File cacheDir = getCacheDir();
        if (cacheDir.exists()) {
            File[] files = cacheDir.listFiles();
            if (files != null) {
                for (File child : files) {
                    deleteFilesRecursively(child);
                }
            }
        }
    }
815726
@Override
  protected void clearCache() {
    if (lastX != null) lastX[0] = Double.NaN;
    if (lastXBatch != null) lastXBatch[0] = Double.NaN;
    if (lastVBatch != null) lastVBatch[0] = Double.NaN;
  }
1252444
private void cleanupCachedState() {
    int total = 0;
    int expired = 0;
    Iterator<Map.Entry<Id, Object>> it = state.entrySet().iterator();
    while (it.hasNext()) {
      ++total;
      Map.Entry<Id, Object> entry = it.next();
      Object obj = entry.getValue();
      if (obj instanceof Meter && ((Meter) obj).hasExpired()) {
        ++expired;
        it.remove();
      }
    }
    logger.debug("removed {} expired entries from cache out of {} total", expired, total);
  }
1206660
def flush(self):
        
        if self._cache is None:
            return []
        with self._cache as c:
            flushed_items = list(c.out_deque)
            c.out_deque.clear()
            cached_reqs = [item.extract_request() for item in flushed_items]
            cached_reqs = [req for req in cached_reqs if req is not None]
            return cached_reqs
790078
private void sanitizeDiskCache() {
        File[] cachedFiles = new File(diskCacheDirectory).listFiles();
        if (cachedFiles == null) {
            return;
        }
        for (File f : cachedFiles) {
        	// if file older than expirationInMinutes, remove it
        	long lastModified = f.lastModified();
        	Date now = new Date();
        	long ageInMinutes = ((now.getTime() - lastModified) / (1000*60));
        	
        	if (ageInMinutes >= expirationInMinutes) {
        		Log.d(name, "DISK cache expiration for file " + f.toString());
        		f.delete();
        	}
        }
	}