Prepare to build cache

@throws InterruptedException
426760
public static void prepare() throws InterruptedException {
		semaphore.acquire();
		if (cacheReference == masterCache) {
			slaveCache.clear();
		} else {
			masterCache.clear();
		}
	}
1237170
private void setupCacheThrough() {
    if (config.getCacheLoaderFactory() != null) {
      final CacheLoader<K, V> clf = config.getCacheLoaderFactory().create();
      cache2kConfiguration.setAdvancedLoader(
        new CustomizationReferenceSupplier<AdvancedCacheLoader<K, V>>(
          new CloseableLoader() {

            @Override
            public void close() throws IOException {
              if (clf instanceof Closeable) {
                ((Closeable) clf).close();
              }
            }

            @Override
            public V load(final K key, final long currentTime, final CacheEntry<K, V> currentEntry) {
              return clf.load(key);
            }

          }));
    }
    if (config.getCacheWriterFactory() != null) {
      final javax.cache.integration.CacheWriter<? super K, ? super V> cw = config.getCacheWriterFactory().create();
      cache2kConfiguration.setWriter(new CustomizationReferenceSupplier<CacheWriter<K, V>>(new CloseableWriter() {
        @Override
        public void write(final K key, final V value) {
          Cache.Entry<K, V> ce = new Cache.Entry<K, V>() {
            @Override
            public K getKey() {
              return key;
            }

            @Override
            public V getValue() {
              return value;
            }

            @Override
            public <T> T unwrap(Class<T> clazz) {
              throw new UnsupportedOperationException("unwrap entry not supported");
            }
          };
          cw.write(ce);
        }

        @Override
        public void delete(final Object key) {
          cw.delete(key);
        }

        @Override
        public void close() throws IOException {
          if (cw instanceof Closeable) {
            ((Closeable) cw).close();
          }
        }
      }));
    }
  }
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'];
    }
662165
protected function prepareCacheStore()
    {
        if ($this->retrieve('expires') != $this->throttle->getExpires()) {
            $this->forget('requests');
            $this->forget('expires');
            $this->forget('reset');
        }
    }
961588
public function build()
    {
        if ($this->cacheProvider->fetch($this->getCacheKey())) {
            return;
        }

        $this->doBuild();
        $this->cacheProvider->save($this->getCacheKey(), true);
    }
1338460
protected void reloadCache()
        throws InstallationException
    {
        try {
            LOG.info("Reloading Cache");
            Context.begin();
            if (RunLevel.isInitialisable()) {
                RunLevel.init("shell");
                RunLevel.execute();
            }
            Context.commit();
        } catch (final EFapsException e) {
            throw new InstallationException("Reload cache failed", e);
        }
    }
271794
public function build(): RequestCachedResponseRequest
	{
		$instance = new RequestCachedResponseRequest();
		if ($this->cacheId === null) {
			throw new BuilderException('Property [cacheId] is required.');
		}
		$instance->cacheId = $this->cacheId;
		if ($this->requestURL === null) {
			throw new BuilderException('Property [requestURL] is required.');
		}
		$instance->requestURL = $this->requestURL;
		if ($this->requestHeaders === null) {
			throw new BuilderException('Property [requestHeaders] is required.');
		}
		$instance->requestHeaders = $this->requestHeaders;
		return $instance;
	}
685885
@Override
    public ServiceCache<T> build()
    {
        if (executorService != null)
        {
            return new ServiceCacheImplExt<>(discovery, name, executorService);
        }
        else
        {
            return new ServiceCacheImplExt<>(discovery, name, threadFactory);
        }
    }
1110669
@Start(priority = 20)
   public void start() {
      cacheName = cache.wired().getName();
      isInvalidationMode = configuration.clustering().cacheMode().isInvalidation();
      isTransactional = configuration.transaction().transactionMode().isTransactional();
      isTotalOrder = configuration.transaction().transactionProtocol().isTotalOrder();
      timeout = configuration.clustering().stateTransfer().timeout();

      CacheMode mode = configuration.clustering().cacheMode();
      isFetchEnabled = mode.needsStateTransfer() &&
              (configuration.clustering().stateTransfer().fetchInMemoryState() || configuration.persistence().fetchPersistentState());

      rpcOptions = new RpcOptions(DeliverOrder.NONE, timeout, TimeUnit.MILLISECONDS);

      stateRequestExecutor = new LimitedExecutor("StateRequest-" + cacheName, stateTransferExecutor, 1);
      running = true;
   }
1201467
public void start()
    {
        pen.start();
        try
        {
            cache.start();
        }
        catch ( Exception e )
        {
            ThreadUtils.checkInterrupted(e);
            Throwables.propagate(e);
        }
    }
597067
public static void initialize()
        throws CacheReloadException
    {
        if (InfinispanCache.get().exists(BundleMaker.NAMECACHE)) {
            InfinispanCache.get().<UUID, Type>getCache(BundleMaker.NAMECACHE).clear();
            InfinispanCache.get().<UUID, Type>getCache(BundleMaker.CACHE4BUNDLE).clear();
            InfinispanCache.get().<UUID, Type>getCache(BundleMaker.CACHE4BUNDLEMAP).clear();
        } else {
            InfinispanCache.get().<UUID, Type>getCache(BundleMaker.NAMECACHE)
                            .addListener(new CacheLogListener(BundleMaker.LOG));
            InfinispanCache.get().<UUID, Type>getCache(BundleMaker.CACHE4BUNDLE)
                            .addListener(new CacheLogListener(BundleMaker.LOG));
            InfinispanCache.get().<UUID, Type>getCache(BundleMaker.CACHE4BUNDLEMAP)
                            .addListener(new CacheLogListener(BundleMaker.LOG));
        }
    }
805801
public void waitForData() throws InterruptedException {
        try {
            if (registryRemote == null) {
                waitForValue();
                return;
            }
            getRegistryRemote().waitForData();
        } catch (CouldNotPerformException ex) {
            ExceptionPrinter.printHistory("Could not wait until " + getName() + " is ready!", ex, logger);
        }
    }
429195
public static function buildCache()
    {
        QRtools::markTime('before_build_cache');

        $mask = new QRmask();
        for ($a=1; $a <= Constants::QRSPEC_VERSION_MAX; $a++) {
            $frame = QRspec::newFrame($a);
            if (Constants::QR_IMAGE) {
                $fileName = Constants::QR_CACHE_DIR.'frame_'.$a.'.png';
                QRimage::png(self::binarize($frame), $fileName, 1, 0);
            }

            $width = count($frame);
            $bitMask = array_fill(0, $width, array_fill(0, $width, 0));
            for ($maskNo=0; $maskNo<8; $maskNo++)
                $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true);
        }

        QRtools::markTime('after_build_cache');
    }
598189
@Override
  public AWSElasticCacheClient build() throws IOException {

    AWSElasticCacheClient memcachedClient =
        new AWSElasticCacheClient(this.sessionLocator, this.sessionComparator, this.bufferAllocator,
            this.configuration, this.socketOptions, this.commandFactory, this.transcoder,
            this.stateListeners, this.authInfoMap, this.connectionPoolSize, this.connectTimeout,
            this.name, this.failureMode, configAddrs, this.pollConfigIntervalMs);
    this.configureClient(memcachedClient);

    return memcachedClient;
  }
875561
public void startup() throws InterruptedException {
        final int maxCacheConnectionPerThread = serverConfig.getMaxConnections() / processors.length;
        logger.debug("start {} Processor threads",processors.length);
        for (int i = 0; i < processors.length; i++) {
            processors[i] = new Processor(handlerFactory, stats, maxRequestSize, maxCacheConnectionPerThread);
            Utils.newThread("jafka-processor-" + i, processors[i], false).start();
        }
        Utils.newThread("jafka-acceptor", acceptor, false).start();
        acceptor.awaitStartup();
    }
425993
protected void initCaches(int cacheSize) {

        m_offlineJsps = CmsMemoryMonitor.createLRUCacheMap(cacheSize);
        m_onlineJsps = CmsMemoryMonitor.createLRUCacheMap(cacheSize);
    }
1238107
@SuppressWarnings("unchecked")
    public void loadCache() {
        if (!cacheManager.isNeedPersist()) {
            return;
        }
        File file = getSaveFile();
        if (null == file) {
            return;
        }
        if (!file.exists()) {
            return;
        }
        BufferedInputStream bis = null;
        try {
            FileInputStream fis = new FileInputStream(file);
            bis = new BufferedInputStream(fis);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte buf[] = new byte[1024];
            int len = -1;
            while ((len = bis.read(buf)) != -1) {
                baos.write(buf, 0, len);
            }
            byte retArr[] = baos.toByteArray();
            Object obj = getPersistSerializer().deserialize(retArr, null);
            if (null != obj && obj instanceof ConcurrentHashMap) {
                cacheManager.getCache().putAll((ConcurrentHashMap<String, Object>) obj);
            }
        } catch (Exception ex) {
            logger.error(ex.getMessage(), ex);
        } finally {
            if (null != bis) {
                try {
                    bis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }