Command Palette

Search for a command to run...

Upstash/Upstash Cache Badge

Upstash Cache Badge

Inline cache status indicator showing HIT/MISS/STALE/EXPIRED states with TTL countdown.

Open in v0Open in
HIT
TTL: 2m
MISS
STALE
EXPIRED

Overview

Display cache status with color-coded badges. Shows live TTL countdown for hits and optional refresh button for misses/stale/expired states.

Installation

npx shadcn@latest add @elements/upstash-cache-badge

Usage

import { UpstashCacheBadge } from "@/components/elements/upstash/upstash-cache-badge";

export function CacheStatus({ cacheResult }) {
  return (
    <UpstashCacheBadge
      status={cacheResult.hit ? "hit" : "miss"}
      ttl={cacheResult.ttl}
      onRefresh={() => revalidate()}
    />
  );
}

Props

PropTypeDefaultDescription
status"hit" | "miss" | "stale" | "expired"-Cache status
ttlnumber-Time to live in seconds
showTtlbooleantrueShow TTL countdown
onRefresh() => void-Refresh callback (shows button for miss/stale/expired)
size"sm" | "md" | "lg""md"Badge size
classNamestring-Additional CSS classes

Status Colors

StatusColorDescription
hitGreenCache hit, data is fresh
missOrangeCache miss, data was fetched
staleYellowData is stale but usable
expiredRedCache entry has expired

Features

  • Color-coded status badges
  • Live TTL countdown
  • Refresh button for non-hit states
  • Multiple size variants
  • Monospace font for TTL display