# alastairtree/LazyCache

An easy to use thread safe in-memory caching service with a simple developer friendly API for c#

Repository: https://github.com/alastairtree/LazyCache
Canonical: https://ross.abutalabs.com/products/lazycache
Homepage: https://nuget.org/packages/LazyCache
Language: C#
License: MIT
License Family: permissive
Topics: c-sharp, cache, inmemory, objectcache, lazy, performance
Last push: 2025-10-09T12:22:13+00:00

## Health v2 (maintenance only)
Score: 44/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 46, release rhythm 8, longevity 100
- inputs: {"age_days": 4571, "days_push": 328, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1757, forks 163 (observed 2026-08-28T04:05:32.313241+00:00)

## What it is
LazyCache is a thread-safe in-memory caching library for .NET with a simple generics-based GetOrAdd API built on Microsoft.Extensions.Caching and Lazy<T>. It guarantees cachable delegates execute only once, even under heavy load.

## Use cases
- cache expensive database query results in memory
- avoid duplicate concurrent cache misses for the same key
- cache web service or API call responses in a dotnet app
- add caching to .NET code without writing double-checked locking
- cache complex object graph building routines
- share a single in-memory cache across an application via dependency injection

## When to choose
- you want a simple, developer-friendly in-memory cache for .NET with atomic GetOrAdd semantics
- you need thread-safe caching that executes factory delegates exactly once under load
- you want a lightweight alternative to managing MemoryCache locking patterns yourself

## When to avoid
- you are starting a new ASP.NET Core project - Microsoft's built-in HybridCache now solves most of the same problems with better long-term support
- you need distributed caching across multiple servers
- you need cache eviction policies beyond what MemoryCache provides

## Facets
- artifact type: library
- maturity: maintenance
- function: caching
- domain: developer-tools, performance, backend
- platform: dotnet, cross-platform
- tags: in-memory-cache, thread-safe, getoradd, lazy-evaluation, dotnet

## Member repositories
- alastairtree/LazyCache (main) score 44

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:32.313241+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-30T03:27:38.680056+00:00, confidence not recorded.
  - readme: https://github.com/alastairtree/LazyCache (fetched 2026-08-28T04:05:32.313241+00:00, sha 35d29131f4d2)
  - homepage: https://nuget.org/packages/LazyCache (fetched 2026-08-29T11:05:47.502821+00:00, sha 878bcc4579a5)
  - site_page: https://www.nuget.org/policies/About (fetched 2026-08-29T11:05:47.512818+00:00, sha a113b8a074c9)
- Data as of 2026-08-30T08:39:29.467469+00:00.
