Lewati ke konten
TakoAPI
Kembali ke skill

smart-cache

oleh raghulpasupathi

CLI Utilities
493Unduhan dilaporkan oleh clawskills.sh
0Tayangan
0 sukaMasuk untuk menyukai skill ini
—Belum ada penilaian
Penilaian Anda

Ringkasan

Intelligent caching with LRU/LFU strategies and TTL management.

Deskripsi

Apa yang Dilakukan Skill Ini

SmartCache is a JavaScript class implementing in-memory caching with LRU and LFU eviction strategies. It supports configurable max size, per-entry TTL, and returns hit/miss metadata on every read. Cache stats including hit rate and current size are available via getStats().

Ships both LRU and LFU strategies in one class, so you can switch eviction behavior with a single config change instead of swapping libraries.

Kapan Menggunakannya

  • Caching API responses to avoid redundant network calls
  • Storing computed query results during request handling
  • Reducing repeated database lookups in web servers
  • Holding parsed config or template data with automatic expiration
  • Throttling expensive function calls by keying on input

Contoh Alur Kerja

INPUT

User asks: cache user profile data fetched from an API with a 60-second TTL

AGENT
  1. 1

    Instantiates SmartCache with strategy 'lru' and maxSize 500

  2. 2

    Calls cache.set('user:42', profileData, 60000) after fetching from the API

  3. 3

    On the next request, calls cache.get('user:42') and checks result.hit

  4. 4

    If hit is true, returns result.value directly without calling the API

  5. 5

    Calls cache.getStats() to monitor fill rate and eviction pressure

OUTPUT

Subsequent requests for the same user return cached data immediately; stats show cache size and current hit rate

Instalasi

clawhub install raghulpasupathi/smart-cache

Jalankan perintah CLI-nya, atau tempel prompt ke Claude Code, Cursor, Codex, atau coding agent apa pun yang Anda pakai.

Tautan