Skip to content

Commit c694456

Browse files
committed
System Cache storage_location WIP
1 parent 87cbd10 commit c694456

1 file changed

Lines changed: 119 additions & 3 deletions

File tree

src/routes/(protected)/system/cache/+page.svelte

Lines changed: 119 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,28 @@
139139
await Promise.all([fetchCacheConfig(), fetchCacheInfo()]);
140140
}
141141
142+
// Compute storage location statistics
143+
let storageStats = $derived.by(() => {
144+
if (!cacheInfo?.namespaces) return null;
145+
146+
const stats = {
147+
redis: 0,
148+
memory: 0,
149+
both: 0,
150+
unknown: 0,
151+
};
152+
153+
for (const ns of cacheInfo.namespaces) {
154+
const location = ns.storage_location?.toLowerCase();
155+
if (location === "redis") stats.redis++;
156+
else if (location === "memory") stats.memory++;
157+
else if (location === "both") stats.both++;
158+
else stats.unknown++;
159+
}
160+
161+
return stats;
162+
});
163+
142164
onMount(() => {
143165
refreshAll();
144166
});
@@ -396,7 +418,7 @@
396418
</p>
397419
</div>
398420
{:else if cacheInfo}
399-
<div class="mb-6 grid grid-cols-1 gap-4 md:grid-cols-3">
421+
<div class="mb-6 grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4">
400422
<div
401423
class="rounded-lg border border-gray-200 bg-white p-6 shadow-sm dark:border-gray-700 dark:bg-gray-800"
402424
>
@@ -433,6 +455,54 @@
433455
{cacheInfo.redis_available ? "Yes" : "No"}
434456
</div>
435457
</div>
458+
{#if storageStats}
459+
<div
460+
class="rounded-lg border border-gray-200 bg-white p-6 shadow-sm dark:border-gray-700 dark:bg-gray-800"
461+
>
462+
<div class="text-sm font-medium text-gray-600 dark:text-gray-400">
463+
Storage Locations
464+
</div>
465+
<div class="mt-2 space-y-1 text-sm">
466+
{#if storageStats.redis > 0}
467+
<div class="flex items-center justify-between">
468+
<span class="text-gray-700 dark:text-gray-300">Redis:</span>
469+
<span
470+
class="font-semibold text-purple-600 dark:text-purple-400"
471+
>{storageStats.redis}</span
472+
>
473+
</div>
474+
{/if}
475+
{#if storageStats.memory > 0}
476+
<div class="flex items-center justify-between">
477+
<span class="text-gray-700 dark:text-gray-300">Memory:</span
478+
>
479+
<span class="font-semibold text-blue-600 dark:text-blue-400"
480+
>{storageStats.memory}</span
481+
>
482+
</div>
483+
{/if}
484+
{#if storageStats.both > 0}
485+
<div class="flex items-center justify-between">
486+
<span class="text-gray-700 dark:text-gray-300">Both:</span>
487+
<span
488+
class="font-semibold text-green-600 dark:text-green-400"
489+
>{storageStats.both}</span
490+
>
491+
</div>
492+
{/if}
493+
{#if storageStats.unknown > 0}
494+
<div class="flex items-center justify-between">
495+
<span class="text-gray-700 dark:text-gray-300"
496+
>Unknown:</span
497+
>
498+
<span class="font-semibold text-gray-600 dark:text-gray-400"
499+
>{storageStats.unknown}</span
500+
>
501+
</div>
502+
{/if}
503+
</div>
504+
</div>
505+
{/if}
436506
</div>
437507

438508
{#if cacheInfo.namespaces && cacheInfo.namespaces.length > 0}
@@ -513,14 +583,60 @@
513583
<div class="mt-1">
514584
{#if namespace.storage_location}
515585
<span
516-
class="inline-flex items-center rounded-full px-3 py-1 text-xs font-medium {namespace.storage_location.toLowerCase() ===
586+
class="inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium {namespace.storage_location.toLowerCase() ===
517587
'redis'
518588
? 'bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300'
519589
: namespace.storage_location.toLowerCase() ===
520590
'memory'
521591
? 'bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300'
522-
: 'bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300'}"
592+
: namespace.storage_location.toLowerCase() ===
593+
'both'
594+
? 'bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300'
595+
: 'bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300'}"
523596
>
597+
{#if namespace.storage_location.toLowerCase() === "redis"}
598+
<svg
599+
class="h-3 w-3"
600+
fill="none"
601+
stroke="currentColor"
602+
viewBox="0 0 24 24"
603+
>
604+
<path
605+
stroke-linecap="round"
606+
stroke-linejoin="round"
607+
stroke-width="2"
608+
d="M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"
609+
/>
610+
</svg>
611+
{:else if namespace.storage_location.toLowerCase() === "memory"}
612+
<svg
613+
class="h-3 w-3"
614+
fill="none"
615+
stroke="currentColor"
616+
viewBox="0 0 24 24"
617+
>
618+
<path
619+
stroke-linecap="round"
620+
stroke-linejoin="round"
621+
stroke-width="2"
622+
d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z"
623+
/>
624+
</svg>
625+
{:else if namespace.storage_location.toLowerCase() === "both"}
626+
<svg
627+
class="h-3 w-3"
628+
fill="none"
629+
stroke="currentColor"
630+
viewBox="0 0 24 24"
631+
>
632+
<path
633+
stroke-linecap="round"
634+
stroke-linejoin="round"
635+
stroke-width="2"
636+
d="M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"
637+
/>
638+
</svg>
639+
{/if}
524640
{namespace.storage_location}
525641
</span>
526642
{:else}

0 commit comments

Comments
 (0)