본문으로 건너뛰기
TakoAPI
스킬로 돌아가기

smart-cache

raghulpasupathi 제작

CLI Utilities
493clawskills.sh가 보고한 다운로드 수
0조회수
좋아요 0개로그인하면 이 스킬에 좋아요를 누를 수 있습니다
—아직 평가 없음
내 평가

요약

Intelligent caching with LRU/LFU strategies and TTL management.

설명

이 스킬이 하는 일

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.

사용 시점

  • 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

예시 워크플로

입력

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

에이전트
  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

출력

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

설치

clawhub install raghulpasupathi/smart-cache

CLI 명령을 실행하거나, 프롬프트를 Claude Code, Cursor, Codex 등 사용하는 코딩 에이전트에 붙여넣으세요.

링크