Skip to content

Commit

Permalink
adding additional options for caching
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic committed Jun 4, 2024
1 parent 37e1a7f commit 8c30430
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 12 deletions.
38 changes: 26 additions & 12 deletions src/Cache/AbstractManifestCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,32 @@ public function setAllCache($ignoreCache = []): void
}
}

/**
* Unset all manifest cache.
*
* @return void
*/
public function deleteAllCache(): void
{
$data = \array_keys($this->getCacheBuilder());

foreach ($data as $cache) {
$this->deleteCache($cache);
}
}

/**
* Unset cache item by type.
*
* @param string $cacheType Type of the cache.
*
* @return void
*/
public function deleteCache(string $cacheType = self::TYPE_BLOCKS): void
{
\delete_transient(self::TRANSIENT_NAME . $this->getCacheName() . "_{$cacheType}");
}

/**
* Set assets static cache to the store helpers used in view files.
*
Expand Down Expand Up @@ -259,18 +285,6 @@ protected function getCache(string $cacheType = self::TYPE_BLOCKS): array
return \json_decode($cache, true) ?? [];
}

/**
* Unset cache.
*
* @param string $cacheType Type of the cache.
*
* @return void
*/
protected function deleteCache(string $cacheType = self::TYPE_BLOCKS): void
{
\delete_transient(self::TRANSIENT_NAME . $this->getCacheName() . "_{$cacheType}");
}

/**
* Get cache builder.
*
Expand Down
25 changes: 25 additions & 0 deletions src/Cache/ManifestCacheInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,29 @@ public function getManifestCacheTopItem(string $key, string $cacheType = Abstrac
* @return array<string, mixed> Array of cache item.
*/
public function getManifestCacheSubItem(string $key, string $path, string $cacheType = AbstractManifestCache::TYPE_BLOCKS): array;

/**
* Set all cache.
*
* @param array<string> $ignoreCache Array of cache to ignore.
*
* @return void
*/
public function setAllCache($ignoreCache = []): void;

/**
* Unset all manifest cache.
*
* @return void
*/
public function deleteAllCache(): void;

/**
* Unset cache item by type.
*
* @param string $cacheType Type of the cache.
*
* @return void
*/
public function deleteCache(string $cacheType = AbstractManifestCache::TYPE_BLOCKS): void;
}

0 comments on commit 8c30430

Please sign in to comment.