Perform validation on SerpFetcher constructor arguments.
@param  string $cacheDir
@param  int    $cacheTTL
@param  bool   $caching
@param  bool   $cacheForever
@param  string $charset
494004
public static function argsValidation($cacheDir, $cacheTTL, $caching,
                                          $cacheForever, $charset)
    {
        if (!self::validateDirName($cacheDir))
            throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $cacheDir: please supply a valid non-empty string.');

        if (!self::validateExpirationTime($cacheTTL))
            throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $cacheTTL: please supply a positive integer.');

        if (!self::validateCacheOpt($caching))
            throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $caching: please supply a boolean value.');

        if (!self::validateCacheOpt($cacheForever))
            throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $cacheForever: please supply a boolean value.');

        if (!self::validateCharset($charset))
            throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $charset: please supply a valid non-empty string.');
    }
678501
public static function validateKey($key): void
    {
        if (!is_string($key)) {
            throw new InvalidArgumentException(sprintf(
                'Cache key must be string, "%s" given',
                is_object($key) ? get_class($key) : gettype($key)
            ));
        }
        if (!isset($key[0])) {
            throw new InvalidArgumentException('Cache key length must be greater than zero');
        }
        if (isset($key[strcspn($key, '{}()/\@:')])) {
            throw new InvalidArgumentException(sprintf('Cache key "%s" contains reserved characters {}()/\@:', $key));
        }
    }
488508
public int
verify(RRset set, Cache cache) {
	Iterator sigs = set.sigs();
	if (Options.check("verbosesec"))
		System.out.print("Verifying " + set.getName() + "/" +
				 Type.string(set.getType()) + ": ");
	if (!sigs.hasNext()) {
		if (Options.check("verbosesec"))
			System.out.println("Insecure");
		return DNSSEC.Insecure;
	}
	while (sigs.hasNext()) {
		RRSIGRecord sigrec = (RRSIGRecord) sigs.next();
		if (verifySIG(set, sigrec, cache) == DNSSEC.Secure) {
			if (Options.check("verbosesec"))
				System.out.println("Secure");
			return DNSSEC.Secure;
		}
	}
	if (Options.check("verbosesec"))
		System.out.println("Failed");
	return DNSSEC.Failed;
}
186663
@SuppressWarnings("unchecked")
  private void configureViaSettersDirect(HeapCache<K,V> c) {
    if (config.getLoader() != null) {
      Object obj =  c.createCustomization(config.getLoader());
      if (obj instanceof CacheLoader) {
        final CacheLoader<K,V> _loader = (CacheLoader) obj;
        c.setAdvancedLoader(new AdvancedCacheLoader<K, V>() {
          @Override
          public V load(final K key, final long currentTime, final CacheEntry<K, V> currentEntry) throws Exception {
            return _loader.load(key);
          }
        });
      } else {
        final FunctionalCacheLoader<K,V> _loader = (FunctionalCacheLoader) obj;
        c.setAdvancedLoader(new AdvancedCacheLoader<K, V>() {
          @Override
          public V load(final K key, final long currentTime, final CacheEntry<K, V> currentEntry) throws Exception {
            return _loader.load(key);
          }
        });
      }
    }
    if (config.getAdvancedLoader() != null) {
      final AdvancedCacheLoader<K,V> _loader = c.createCustomization(config.getAdvancedLoader());
      AdvancedCacheLoader<K,V> _wrappedLoader = new WrappedAdvancedCacheLoader<K, V>(c, _loader);
      c.setAdvancedLoader(_wrappedLoader);
    }
    if (config.getExceptionPropagator() != null) {
      c.setExceptionPropagator(c.createCustomization(config.getExceptionPropagator()));
    }
    c.setCacheConfig(config);
  }
107924
public function set(
        callable $inputDataFunction,
        $tHashKeys,
        $tRedisTags,
        int $iCache = null
    ): self {
        try {
            if ($tHashKeys === [] || $tHashKeys === null || (\is_string($tHashKeys) && trim($tHashKeys) === '')) {
                throw new InvalidArgumentException('HashKey is required!', 1);
            }

            $tRedisTags = (array)$tRedisTags;
            $tHashKeys  = (array)$tHashKeys;
            $iCache     = $iCache ?? $this->defaultTtl;

            $hashKey = $this->genHash($tHashKeys);

            if ($this->isEnabled === false) {
                $this->logger->debug(sprintf('CACHE [%s]: cache omitted [not enabled]', $hashKey));
                $this->userData = $inputDataFunction();
            } elseif ($iCache > 0) {
                $oCachedItem = $this->oCache->getItem($hashKey);
                //do każdego zapytania dajemy TAG związany z projektem
                $tRedisTags = array_unique(array_merge([$this->projectHash], $tRedisTags));

                if (!$oCachedItem->isHit() || $oCachedItem->get() === null) {
                    $this->logger->debug(sprintf('CACHE [%s]: old or NULL, reset [ttl=%s]', $hashKey, $iCache));
                    $this->userData = $inputDataFunction();
                    $oCachedItem
                        ->set($this->userData)
                        ->setTags($tRedisTags)
                        ->expiresAfter($iCache)
                    ;
                    $this->oCache->save($oCachedItem);
                } else {
                    $this->logger->debug(sprintf('CACHE [%s]: getting from cache', $hashKey));
                    $this->userData = $oCachedItem->get();
                }
            } else {
                $this->logger->debug(sprintf('CACHE [%s]: cache omitted [ttl=0]', $hashKey));
                $this->userData = $inputDataFunction();
            }

            return $this;
        } catch (\Exception $e) {
            $this->logger->warning(sprintf('CACHE Error: %s. Using fallback function.', $e->getMessage()));
            $this->userData = $inputDataFunction();

            return $this;
        }
    }
1100137
private function isCacheUpToDate($cachedFile, $templateFile)
    {
        if (!file_exists($cachedFile)) {
            return false;
        }

        $cacheTime = filemtime($cachedFile);
        $templTime = filemtime($templateFile);

        return $cacheTime == $templTime;
    }
1225731
protected function validateFolder($exposeFolder)
    {
        if (strstr($exposeFolder, '.')) {
            return false;
        }
        if (strpos($exposeFolder, '/') === 0) {
            return false;
        }
        if (strpos($exposeFolder, '\\') === 0) {
            return false;
        }
        return true;
    }
327300
public function warmUp($cacheDir)
    {
        if (null === $this->finder) {
            return;
        }

        $twig = $this->container->get('twig');

        $templates = $this->finder->findAllTemplates();

        foreach ($this->paths as $path => $namespace) {
            $templates = array_merge($templates, $this->findTemplatesInFolder($namespace, $path));
        }

        foreach ($templates as $template) {
            try {
                $twig->loadTemplate($template);
            } catch (Error $e) {
                // problem during compilation, give up
            }
        }
    }
57802
static protected function check()
    {
        empty(self::$cachepath) && self::$cachepath = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Cache' . DIRECTORY_SEPARATOR;
        self::$cachepath = rtrim(self::$cachepath, '/\\') . DIRECTORY_SEPARATOR;
        if (!is_dir(self::$cachepath) && !mkdir(self::$cachepath, 0755, true)) {
            return false;
        }
        return true;
    }
308229
public function warmUp($cacheDir)
    {
        $pages = $this->kernel->getContainer()->get('kunstmaan_extra.content_type')->getAllContentTypeClasses();
        $pageparts = $this->kernel->getContainer()->getParameter('kunstmaan_page_part.page_parts_presets');

        $classes = array_unique(array_filter(iterator_to_array($this->getClasses($pages, $pageparts))));

        $controllerName = basename($this->path, '.php');

        $code = $this->generateCode($classes, $controllerName);

        file_put_contents($this->path, $code);
    }
600345
public void setDebugCacheDir(File cacheDir) {
        if (sDebug) {
            LogUtils.v(TAG, "setCacheDir() cacheDir=" + cacheDir);
        }
        mCacheDir = cacheDir;
        checkCacheDir(false);
    }
772089
public function warmUp($cacheDir)
    {
        if (!$this->viewReferenceRepository->hasReference()) {
            $this->viewReferenceManager->saveReferences(
                $this->viewHelper->buildViewsReferences()
            );
        }
    }
63934
public function warmUp($cacheDir): void
    {
        if ($this->configLoader instanceof WarmableInterface) {
            $this->configLoader->warmUp($cacheDir);
        }
    }
694647
public function fileCacheSet($key, $value, $cache_time = 86400)
    {
        if ($this->isSingle()) {
            FilecacheKit::add($key, $value, $cache_time);
        }
    }
345090
public function check($cacheFile, $cacheTime)
    {
        // 缓存文件不存在, 直接返回false
        if (!file_exists($cacheFile)) {
            return false;
        }

        if (0 != $cacheTime && time() > filemtime($cacheFile) + $cacheTime) {
            // 缓存是否在有效期
            return false;
        }

        return true;
    }
762543
public function isExist($cacheName, $cacheDir = false)
    {
        $cacheDir = $cacheDir == false ? self::$cacheDir : $cacheDir;
        $dir = $cacheDir."/".$cacheName;

        return file_exists($dir);
    }
475257
public function warmUp($cacheDir)
    {
        $baseDir = $this->annotationDir.DIRECTORY_SEPARATOR.'Sidus'.DIRECTORY_SEPARATOR.'EAV'.DIRECTORY_SEPARATOR;
        if (!@mkdir($baseDir, 0777, true) && !is_dir($baseDir)) {
            throw new \RuntimeException("Unable to create annotations directory: {$baseDir}");
        }

        foreach ($this->familyRegistry->getFamilies() as $family) {
            $content = $this->getFileHeader($family);

            foreach ($family->getAttributes() as $attribute) {
                $content .= $this->getAttributeMethods($family, $attribute);
            }

            $content .= "}\n";

            $this->writeFile($baseDir.$family->getCode().'.php', $content);
        }
    }