/*
private boolean isOK(Resource cacheResource) { return cacheResource.exists() &&
(cacheResource.lastModified()+timespan.getMillis()>=System.currentTimeMillis()); }
173267
private int doContentCache() throws IOException {

	// file
	cacheItem = generateCacheResource(key, true);
	// use cache
	if (cacheItem.isValid(timespan)) {
	    pageContext.write(cacheItem.getValue());
	    doCaching = false;
	    return SKIP_BODY;
	}
	doCaching = true;
	return EVAL_BODY_BUFFERED;
    }
36165
@Override
	public boolean isCacheable() {
		boolean supportsConditionals = has("Last-Modified", this.response) || has("ETag", this.response);
		boolean isCacheable =
				has("Cache-Control", "s-maxage", this.response)
				|| has("Cache-Control", "max-age", this.response)
				|| has("Expires", this.response);
		return supportsConditionals || isCacheable;
	}
1358054
private boolean canOpen(String resourceLocation) {
        if (resourceLocation == null) {
            throw new InvalidArgument("resourceLocation", resourceLocation);
        }

        synchronized (resourceLocation) {
            // find the resource in the cache
            CachedResource cachedResource = cacheLookupService
                    .findInCache(NAMESPACES, resourceLocation);

            if (cachedResource == null) {
                return false;
            }

            String indexPath = asPath(
                    cachedResource.getLocalFile().getAbsolutePath(),
                    NS_INDEX_FILE_NAME);

            JDBMNamespaceLookup il = new JDBMNamespaceLookup(indexPath);
            try {
                il.open();
                il.close();
            } catch (IOException e) {
                return false;
            }

            return true;
        }
    }
1151344
public boolean isOutOfResources()
    {
        boolean out =
            getThreads()==getMaxThreads() &&
            getIdleThreads()==0;
        
        if (out && !_isOut)
        {
            log.warn("OUT OF THREADS: "+this);
            _warned=System.currentTimeMillis();
            _isLow=true;
            _isOut=true;
        }
        
        return out;
    }
717692
protected void checkCacheVersion() {
        // Be very aggressive in invalidating the cache.
        boolean invalidate = true;
        QueryRunner run = new QueryRunner(ds);
        try {
            long latestVersion = run.query("SELECT version FROM gw_dataversion", Handlers.LONG_HANDLER); //$NON-NLS-1$
            if (latestVersion > -1 && dataVersion > -1 && latestVersion == dataVersion) {
                invalidate = false;
            } else {
                dataVersion = latestVersion;
            }
        } catch (SQLException e) {
            // TODO need to use the gateway logger to log this!
            e.printStackTrace();
        }
        if (invalidate) {
            invalidateCache();
        }
    }
401047
@Override
    public boolean containsCacheId(Object cacheId) {
        boolean found = false;
        if (cacheId != null) {
            found = this.coreCache.containsCacheId(cacheId);
        }
        return found;
    }
1295293
static function hasCompiledTemplate( $key, $timestamp, &$resourceData )
    {
        if ( !eZTemplateCompiler::isCompilationEnabled() )
            return false;
        if ( eZTemplateCompiler::alwaysGenerate() )
            return false;

        $cacheFileName = eZTemplateCompiler::compilationFilename( $key, $resourceData );

        $php = new eZPHPCreator( eZTemplateCompiler::compilationDirectory(), $cacheFileName, eZTemplateCompiler::TemplatePrefix() );
        $canRestore = $php->canRestore( $timestamp );
        $uri = false;
        if ( $canRestore )
            eZDebugSetting::writeDebug( 'eztemplate-compile', "Cache hit for uri '$uri' with key '$key'", 'eZTemplateCompiler::hasCompiledTemplate' );
        else
            eZDebugSetting::writeDebug( 'eztemplate-compile', "Cache miss for uri '$uri' with key '$key'", 'eZTemplateCompiler::hasCompiledTemplate' );
        return $canRestore;
    }
104517
public boolean contains(String resource) {
		boolean result = storage.contains(resource);
		logger.debug("resource '{}' {} in cache", resource, (result ? "is" : "is not"));
		return result; 
	}
286913
@Override
    public boolean isDataInCache(Class<?> clazz, Object cacheKey, long maxTimeInCacheBeforeExpiry) throws CacheCreationException {
        return getObjectPersister(clazz).isDataInCache(cacheKey, maxTimeInCacheBeforeExpiry);
    }
768963
public function cacheExists()
    {
        $cacheFile = $this->getCacheFile();
        if (file_exists($cacheFile) && filemtime($cacheFile) > (time()-$this->cachePeriod)) {
            return(true);
        } else {
            return(false);
        }
    }
292474
public boolean isOver() {
        if (!isOver) {
            final long now = System.currentTimeMillis();
            isOver = now - startTime >= duration;
        }
        return isOver;
    }
625358
@GuardedBy("mLock")
  private boolean maybeUpdateFileCacheSize() {
    long now = mClock.now();
    if ((!mCacheStats.isInitialized()) ||
        mCacheSizeLastUpdateTime == UNINITIALIZED ||
        (now - mCacheSizeLastUpdateTime) > FILECACHE_SIZE_UPDATE_PERIOD_MS) {
      return maybeUpdateFileCacheSizeAndIndex();
    }
    return false;
  }
1204940
private Resource mightCache(String key, Resource fileResource) {
        if ( ! isDevMode() ) {
            lookupCache.put(key,fileResource);
        }
        return fileResource;
    }
687182
protected void checkCacheVersion() {
        // Be very aggressive in invalidating the cache.
        boolean invalidate = true;
        try {
            Get get = new Get.Builder(getDefaultIndexName(), "instance").type("dataVersion").build(); //$NON-NLS-1$ //$NON-NLS-2$
            JestResult result = getClient().execute(get);
            if (result.isSucceeded()) {
                String latestDV = result.getJsonObject().get("_version").getAsString(); //$NON-NLS-1$
                if (latestDV != null && dataVersion != null && latestDV.equals(dataVersion)) {
                    invalidate = false;
                } else {
                    dataVersion = latestDV;
                }
            }
        } catch (IOException e) {
            logger.warn("Elasticsearch is not available, using cache");
            invalidate = false;
        }
        if (invalidate) {
            invalidateCache();
        }
    }
1340961
@Override
	public boolean exists() {
		// Return false if any of the resources in this aggregated resource
		// does not exist
		boolean result = true;
		for (IResource resource : resources) {
			if (!resource.exists()) {
				result = false;
				break;
			}
		}
		return result;
	}
394826
static synchronized CacheInstanceInfo [] getCacheInstanceInfo( CacheServiceImpl cacheService ) {
		CacheInstanceInfo infoOut [] = currentCacheInstanceInfoOut;
		if ( System.currentTimeMillis() - lastPopulate > populateInterval ) {
			if (cacheService!=null) {
				if ( cacheInstanceInfo == null ) {
					cacheInstanceInfo = new CacheInstanceInfo();
				}
				cacheService.populateCacheInstanceInfo( cacheInstanceInfo );
				CacheInstanceInfo.cacheService = cacheService;
				infoOut = new CacheInstanceInfo[allConfigured.size()];
				Iterator i = allConfigured.iterator();
				int x=0;
				while ( i.hasNext() ) {
					String cacheName =  (String)i.next();
					CacheInstanceInfo info = new CacheInstanceInfo();

					info.cacheName      = cacheName;
					info.isActive       = CacheInstanceInfo.allActive.contains(cacheName);
					info.isFactory      = CacheInstanceInfo.allFactory.contains(cacheName);
					info.isFile         = CacheInstanceInfo.allFile.contains(cacheName);
					info.isObjectCache  = CacheInstanceInfo.objectConfigured.contains(cacheName);
					info.isServletCache = CacheInstanceInfo.servletConfigured.contains(cacheName);

					infoOut[x++] = info;
				}
				currentCacheInstanceInfoOut = infoOut;
				CacheInstanceInfo.allConfigured.clear();
				CacheInstanceInfo.allActive.clear();
				CacheInstanceInfo.allFactory.clear();
				CacheInstanceInfo.allFile.clear();
				CacheInstanceInfo.objectConfigured.clear();
				CacheInstanceInfo.servletConfigured.clear();

			}
			lastPopulate = System.currentTimeMillis();
		}
		return infoOut;
	}
1025985
def is_cache_valid(self):
        '''  '''

        if os.path.isfile(self.cache_path_cache):
            mod_time = os.path.getmtime(self.cache_path_cache)
            current_time = time()
            if (mod_time + self.cache_max_age) > current_time:
                if os.path.isfile(self.cache_path_index):
                    return True

        return False