/** * Builds the pages cache * * @param string $language The language to build the cache for. */ public function buildCache($language) { // kill existing caches so they can be re-generated $this->cache->deleteItems(array('keys_' . $language, 'navigation_' . $language)); $keys = $this->getKeys($language); $navigation = $this->getNavigation($language); // build file with navigation structure to feed into editor $fs = new Filesystem(); $cachePath = FRONTEND_CACHE_PATH . '/Navigation/'; $fs->dumpFile($cachePath . 'editor_link_list_' . $language . '.js', $this->dumpEditorLinkList($navigation, $keys, $language)); }
/** * @return $this */ public function unlock() { if ($this->isLocked()) { $this->cache->deleteItems([$this->getKey()]); } return $this; }
/** * Load a localization for the current language from a directory. * * @param string $dir * Directory path. * @param bool $extend * Whether to extend the existing localization object * (true) or replace it (false). * @return bool True if language file found, false otherwise. */ public static function loadFrom($dir, $extend = true) { $file = $dir . '/' . self::$language . '.'; if (isset(self::$cache)) { $cached = self::$cache->getItem($file); if ($cached->isHit()) { $value = $cached->get(); if (is_array($value)) { $localization = new Locale($value); self::load($localization, $extend); return true; } else { self::$cache->deleteItems(array($file)); } } } if (file_exists($file . 'pot')) { return true; } elseif (file_exists($file . 'mo')) { $localization = Locale::readMo($file . 'mo'); } elseif (file_exists($file . 'po')) { $localization = Locale::readPo($file . 'po'); } else { return false; } if (isset(self::$cache)) { // self::$cache->set($file, $localization->getMessages(), 3600); $item = self::$cache->getItem($file); $item->set($localization->getMessages()); $item->expiresAfter(3600); self::$cache->save($item); } self::load($localization, $extend); return true; }
/** * {@inheritdoc} */ public function deleteItems(array $keys, array $tags = []) { $taggedKeys = []; foreach ($keys as $key) { $taggedKeys[] = $this->generateCacheKey($key, $tags); } return $this->pool->deleteItems($taggedKeys); }
/** * Deletes a module setting * * @param string $module * @param string $key */ public function delete($module, $key) { $this->database->delete('modules_settings', 'module = :module and name = :name', array('module' => $module, 'name' => $key)); /* * Instead of invalidating the cache, we could also fetch existing * settings, update them & re-store them to cache. That would save * us the next query to repopulate the cache. * However, there could be race conditions where 2 concurrent * requests write at the same time and one ends up overwriting the * other (unless we do a CAS, but PSR-6 doesn't support that) * Clearing cache will be safe: in the case of concurrent requests * & cache being regenerated while the other is being saved, it will * be cleared again after saving the new setting! */ $this->cache->deleteItems(array('settings')); }
/** * {@inheritdoc} */ public function deleteItems(array $keys) { return $this->pool->deleteItems($keys); }
/** * {@inheritdoc} */ public function deleteItems(array $keys, array $tags = []) { return $this->cache->deleteItems($keys, $tags); }
public function deleteItems(array $keys) { return $this->decorated->deleteItems($keys); }
/** * {@inheritdoc} */ public function deleteItems(array $keys) { return $this->defaultAdapter->deleteItems($keys); }