# jellydator/ttlcache

An in-memory cache with item expiration and generics

Repository: https://github.com/jellydator/ttlcache
Canonical: https://ross.abutalabs.com/products/ttlcache
Language: Go
License: MIT
License Family: permissive
Topics: cache, golang, ttl-cache, generics
Last push: 2026-08-21T07:45:40+00:00

## Health v2 (maintenance only)
Score: 84/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 98, release rhythm 57, longevity 100
- inputs: {"age_days": 4282, "days_push": 12, "days_rel": 72, "gap_med": 369, "n_releases_24m": 2}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1278, forks 145 (observed 2026-08-28T04:04:13.427327+00:00)

## What it is
TTLCache is an in-memory cache library for Go with per-item or cache-wide TTL expiration, built using generics. It offers thread-safe operations, capacity limits, lazy loading, event handlers, and metrics.

## Use cases
- cache api responses in memory with expiration
- add a ttl-based cache to a go service
- limit cache size by item count or cost
- lazily load missing cache values with duplicate suppression
- track cache hits and misses with metrics
- run eviction callbacks when items expire

## When to choose
- you need a lightweight in-process cache with TTL expiration in Go
- you want generics-based type safety without interface{} casts
- you need capacity limits, loaders, or eviction event hooks

## When to avoid
- you need a distributed or shared cache across multiple instances (use Redis)
- your dataset exceeds available memory
- you need persistence or eviction across process restarts

## Facets
- artifact type: library
- maturity: active
- function: caching
- domain: developer-tools, backend, performance
- platform: go
- tags: ttl-cache, in-memory-cache, generics, thread-safe, lru-alternative

## Member repositories
- jellydator/ttlcache (main) score 84

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:04:13.427327+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T05:02:45.828120+00:00, confidence not recorded.
  - readme: https://github.com/jellydator/ttlcache (fetched 2026-08-28T04:04:13.427327+00:00, sha efdb4f47375f)
- Data as of 2026-08-30T08:39:29.467469+00:00.
