Ejemplo n.º 1
0
 /**
  * Returns current instance of the StaticHtmlCache.
  *
  * @return StaticHtmlCache
  */
 public static function getInstance()
 {
     if (!isset(static::$instance)) {
         $cacheProvider = static::getCacheProvider();
         $privateKey = $cacheProvider !== null ? $cacheProvider->getCachePrivateKey() : null;
         static::$instance = new static(\CHTMLPagesCache::getRequestUri(), \CHTMLPagesCache::getHttpHost(), \CHTMLPagesCache::getRealPrivateKey($privateKey));
         static::$instance->enableDebug();
         if ($cacheProvider !== null) {
             static::$instance->setCacheProvider($cacheProvider);
         }
     }
     return static::$instance;
 }
Ejemplo n.º 2
0
 public static function deleteUserCache($userId = false)
 {
     global $USER;
     if ($userId === false && $USER->IsAuthorized()) {
         $userId = $USER->GetID();
     }
     $userId = intval($userId);
     if ($userId > 0) {
         $postfix = \CHTMLPagesCache::getSpaPostfix();
         $privateKey = self::getUserPrefix($userId);
         foreach ($postfix as $item) {
             $realPrivateKey = \CHTMLPagesCache::getRealPrivateKey($privateKey, $item);
             $staticCache = new StaticHtmlCache("/", null, $realPrivateKey);
             $staticCache->delete();
         }
         header("X-Bitrix-Composite-Delete:" . md5(\CHTMLPagesCache::getHttpHost() . $privateKey));
     }
 }