Skip to content

Commit

Permalink
add total amount to gui
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Bähr committed Nov 23, 2023
1 parent 5495498 commit 09f571f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<property name="name" type="string"/>
<property name="description" type="string"/>
<property name="keyPattern" type="string"/>
<property name="totalAmount" type="int"/>
</transfer>

<transfer name="CacheManagerDelete">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ public function getPlugins(): array
{
$transfers = [];
foreach ($this->cacheManagerPluginCollection->getAll() as $plugin) {
$keyPattern = $plugin->getKeyPattern();
$transfers[] = (new CacheManagerPluginTransfer())
->setName($plugin->getName())
->setDescription($plugin->getDescription())
->setKeyPattern($plugin->getKeyPattern());
->setKeyPattern($keyPattern)
->setTotalAmount(count($this->getKeys($keyPattern)));
}

return $transfers;
Expand All @@ -49,7 +51,7 @@ public function deleteCache(CacheManagerDeleteTransfer $cacheManagerDeleteTransf
if ($this->cacheManagerPluginCollection->has($name)) {
$plugin = $this->cacheManagerPluginCollection->get($name);

$keys = $this->storageClient->getKeys($plugin->getKeyPattern());
$keys = $this->getKeys($plugin->getKeyPattern());
$formattedKeys = $this->getFormattedKeys($keys);

$this->storageClient->deleteMulti($formattedKeys);
Expand All @@ -73,4 +75,14 @@ private function getFormattedKeys(array $keys): array
return ltrim($key, Service::KV_PREFIX);
}, $keys);
}

/**
* @param string $keyPattern
*
* @return array
*/
private function getKeys(string $keyPattern): array
{
return $this->storageClient->getKeys($keyPattern);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
use Spryker\Zed\Kernel\AbstractBundleDependencyProvider;
use Spryker\Zed\Kernel\Container;

/**
* @method \ValanticSpryker\Zed\CacheManagerGui\CacheManagerGuiConfig getConfig()
*/
class CacheManagerGuiDependencyProvider extends AbstractBundleDependencyProvider
{
public const CACHE_MANAGER_PLUGINS = 'CACHE_MANAGER_PLUGINS';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<div class="col-md-12">
<dl class="row">Description: {{ plugin.description }}</dl>
<dl class="row">Key Pattern: {{ plugin.keyPattern }}</dl>
<dl class="row">Total Entites: {{ plugin.totalAmount }}</dl>
{{ createActionButton('/cache-manager-gui/index/delete?name=' ~ plugin.name, 'Delete' | trans) }}
</div>
</div>
Expand Down

0 comments on commit 09f571f

Please sign in to comment.