/*
Serve the data from the cache.
17589
function _cacheData(key, value) {
    cache[key] = { timeStamp: _getTimeStamp(), value: value };
    _deletePromiseWaiting(key);
    return value;
}
1315725
function serve(done) {
  gulp.watch(['src/**/*.css'], () => {
    reset();
    gulp.series('build-css', 'generate-preview', outputDevServerInfo);
  });

  gulp.watch(['previewer-src/**', 'patterns.yaml'], () => {
    reset();
    gulp.series('generate-preview-force', outputDevServerInfo)
  });

  browserSync.emitter.on('init', outputDevServerInfo);

  browserSync.init({
    logLevel: 'silent',
    ui: false,
    port: 4321,
    notify: false,
    server: {
      baseDir: __dirname + '/build',
      middleware: [historyApiFallback()],
    },
    startPath: '/',
    open: false
  });
}
809116
def _fill_cache(self):
        """"""
        for irow in range(len(self._table)):
            file_handle = self._make_file_handle(irow)
            self._cache[file_handle.path] = file_handle
478389
public function serve()
    {
        $type       = $this->getSourceType();
        $sources    = $this->getSources();
        $contents   = $this->getContents();
        if ($type!='file' && count($sources)==1) {
            $response_data = array(
                'source'    => $sources[0],
                'content'   => $contents[0],
            );
        } else {
            $response_data = array(
                'sources'   => $sources,
                'contents'  => $contents,
            );
        }

        $errors_collection = $this->getErrors();
        $errors = array();
        foreach ($errors_collection as $_error) {
            $errors[] = $_error->getFullMessage();
        }
        $response_data['errors'] = $errors;

        if ($this->isDebug()) {
            $response_data['dump'] = serialize($this);
        }

        if (Container::get('request')->isMethod('head')) {
            Container::get('response')->fetchHeaders();
            exit(PHP_EOL);
        } else {
            try {
                Container::get('response')->send($response_data);
            } catch (\Exception $e) {
                $this->warning($e->getMessage());
                Container::get('response')
                    ->setContent(array('errors'=>$this->getErrors()))
                    ->fetch();
            }
        }
    }
421158
private void cacheConfig(String oid, JsonSimpleConfig config) {
		if (useCache && config != null) {
			configCache.put(oid, config);
		}
	}
200518
function use_cache ( $key = '' )
		{
			if (empty($_POST))
			{
				$this->cache_filename  =  $this->cache_dir . 'cache_' . md5($_SERVER['REQUEST_URI'] . serialize($key)) . '.ser';
				if (($_SERVER['HTTP_CACHE_CONTROL'] != 'no-cache')  &&  ($_SERVER['HTTP_PRAGMA'] != 'no-cache')  &&  @is_file($this->cache_filename))
				{
					if ((time() - filemtime($this->cache_filename)) < $this->cache_lifetime)
					{
						readfile($this->cache_filename);
						exit;
					}
				}
				ob_start( array( &$this, 'cache_callback' ) );
			}
		}
1049859
function() {
  gulp.task('serve', function() {
    server.listen(serverport);
  });

  gulp.task('copy', function() {
    return gulp.src([paths.src.scripts + '**/*'])
    .pipe(gulp.dest(paths.src.tmp));
  });

  gulp.task('bundle-js:clean', [
    'bundle-js'
  ], cleanTmp);

  gulp.task('bundle-js:dev:clean', [
    'bundle-js:dev'
  ], cleanTmp);

  gulp.task('reload', function() {
    gulp.src(paths.out.base + '**/*')
    .pipe($.cached('reloading'))
    .pipe($.livereload(lrport));
  });
}
374732
function _getCached( cached, data )
	{
		if( !data ){ return cached; }

		let i = -1, len = cached.length;
        while (++i < len) {
            cached[i].data = data;
        }
        return cached;
	}
928141
function getCache(key, doesDateMatter, callback) {
    key = key.replace(/\//g, '-');
    var cacheFile = __dirname + '/' + CACHE_PREFIX + key + '.cache';
    fs.exists(cacheFile, function (exists) {
        if (exists) {
            fs.stat(cacheFile, function (err, stats) {
                if (err) {
                    throw err;
                }
                if (!doesDateMatter || (stats.mtime.valueOf() > (new Date().valueOf() - 60 * 60 * 1000))) {
                    // The cache is less than 60 minutes old so return the contents
                    fs.readFile(cacheFile, function (err, data) {
                        if (err) {
                            console.error('Error reading the cache file at ' + cacheFile);
                            throw err;
                        }
                        var dataString = data.toString();
                        var dataObj;
                        try {
                            dataObj = JSON.parse(dataString);
                        } catch(e) {
                            dataObj = null;
                        }

                        callback(dataObj, stats.mtime);
                        return;
                    });
                } else {
                    // The cache is older than 60 minutes
                    callback(null);
                    return;
                }
            });
        } else {
            // The cache doesn't exist
            callback(null);
            return;
        }
    });
}
282357
protected function loadFromCache() : void
    {
        $data = include $this->cacheFile;
        if (!is_array($data) ||
            !isset($data['routes']) ||
            !is_array($data['routes']) ||
            !isset($data['dispatch_data']) ||
            !is_array($data['dispatch_data'])
        ) {
            throw new \RuntimeException(sprintf(
                'Invalid cache file "%s"',
                $this->cacheFile
            ));
        }

        $this->routes = $data['routes'];
        $this->dispatchData = $data['dispatch_data'];
    }
1275453
protected function loadFromCache()
    {
        $data = $this->dataCache->get($this->cacheIdentifier);
        if ($data !== false) {
            foreach ($data as $propertyName => $propertyValue) {
                $this->{$propertyName} = $propertyValue;
            }
        }
    }
830364
public function flushCache()
    {
        $adapter = $this->driver->getAdapter();

        if ($adapter instanceof CachedAdapter) {
            $adapter->getCache()->flush();
        }
    }
851468
function saveData(data) {
    console.log('saving data', data);
    if (options.cacheKeys) {
      cachedKeys = Object.keys(data);
    }
    if (file === false) {
      return Promise.resolve();
    } else {
      return writeFile(file, JSON.stringify(data, null, 2));
    }
  }
905445
function(_cache,_result){
            var _data = {
                data:_result
            };
            // parse ext headers
            var _keys = _cache.result.headers;
            if (!!_keys){
                _data.headers = _cache.req._$header(_keys);
            }
            // TODO parse other ext data
            return _data;
        }
251158
public static function serve()
    {
        $output = new NullOutput();

        $daux = new Daux(Daux::LIVE_MODE, $output);
        $daux->initializeConfiguration();

        $class = $daux->getProcessorClass();
        if (!empty($class)) {
            $daux->setProcessor(new $class($daux, $output, 0));
        }

        // Set this critical configuration
        // for the tree generation
        $daux->getParams()['index_key'] = 'index';

        // Improve the tree with a processor
        $daux->generateTree();

        $server = new static($daux);

        try {
            $page = $server->handle();
        } catch (NotFoundException $e) {
            $page = new ErrorPage('An error occured', $e->getMessage(), $daux->getParams());
        }

        $server->createResponse($page)->prepare($server->request)->send();
    }
663975
function cacheSet(key, options, val) {
    if (shouldCache(options)) {
      return;
    }

    if (self.options.cache === 'memory') {
      self.cache[key] = val;
      return;
    }

    self.options.cache.set(key, val);
  }
1023758
public void cache(K name, V data) {

		if ( data == null){
			return;
		}
		if ( serializedCache != null){


			logger.debug("Caching {}  {}", name, data);

			serializedCache.put(name,data);


			// every 1000 objects we are writing to disk
			if ( serializedCache.keySet().size() % 1000 == 0 ) {

				flushCache();

			}

		}


	}