# Memory Cache > A zero-dependency TypeScript in-memory cache with TTL expiration, true LRU eviction, wildcard deletion, hooks, and @cached method decorators. # Memory Cache - Package: `@humanspeak/memory-cache` - License: MIT - Requires: TypeScript or JavaScript - Maintained by: [Humanspeak, Inc.](https://humanspeak.com) - Current version: see ## Installation ```bash npm install @humanspeak/memory-cache ``` ```bash pnpm add @humanspeak/memory-cache ``` ## Basic Usage ```typescript import { MemoryCache } from '@humanspeak/memory-cache' const cache = new MemoryCache({ maxSize: 100, ttl: 60_000 }) cache.set('user:123', 'Ada') const value = cache.get('user:123') ``` ## Method Memoization Use the `@cached` decorator to memoize method results with TTL support. ```typescript import { cached } from '@humanspeak/memory-cache' class UserService { @cached({ ttl: 60_000 }) async getUser(id: string) { return fetch(`/api/users/${id}`).then((res) => res.json()) } } ``` ## Key Features - Zero-dependency in-memory cache for TypeScript and JavaScript - TTL expiration for time-bound cache entries - LRU eviction when the cache reaches capacity - `@cached` decorator for method-level memoization - Wildcard pattern deletion for grouped invalidation - Cache statistics and lifecycle hooks for monitoring - Works well for API response caching, session storage, computed values, and database query caching Canonical docs root: https://memory.svelte.page/docs Per-page markdown mirrors: https://memory.svelte.page/docs/.md Full reference (single document): https://memory.svelte.page/llms-full.txt ## Documentation - [@cached Decorator](https://memory.svelte.page/docs/api/cached-decorator.md) — https://memory.svelte.page/docs/api/cached-decorator - [MemoryCache API](https://memory.svelte.page/docs/api/memory-cache.md) — https://memory.svelte.page/docs/api/memory-cache - [Examples](https://memory.svelte.page/docs/examples.md) — https://memory.svelte.page/docs/examples - [API Response Caching](https://memory.svelte.page/docs/examples/api-caching.md) — https://memory.svelte.page/docs/examples/api-caching - [Async Decorator](https://memory.svelte.page/docs/examples/async-decorator.md) — https://memory.svelte.page/docs/examples/async-decorator - [Async Fetching](https://memory.svelte.page/docs/examples/async-fetching.md) — https://memory.svelte.page/docs/examples/async-fetching - [Computed Value Caching](https://memory.svelte.page/docs/examples/computed-values.md) — https://memory.svelte.page/docs/examples/computed-values - [Configuration Cache](https://memory.svelte.page/docs/examples/configuration.md) — https://memory.svelte.page/docs/examples/configuration - [Database Query Caching](https://memory.svelte.page/docs/examples/database-caching.md) — https://memory.svelte.page/docs/examples/database-caching - [Monitoring with Hooks](https://memory.svelte.page/docs/examples/monitoring.md) — https://memory.svelte.page/docs/examples/monitoring - [Multi-Tenant Cache Invalidation](https://memory.svelte.page/docs/examples/multi-tenant.md) — https://memory.svelte.page/docs/examples/multi-tenant - [Rate Limiting](https://memory.svelte.page/docs/examples/rate-limiting.md) — https://memory.svelte.page/docs/examples/rate-limiting - [Service Class Pattern](https://memory.svelte.page/docs/examples/service-class.md) — https://memory.svelte.page/docs/examples/service-class - [Session Storage](https://memory.svelte.page/docs/examples/sessions.md) — https://memory.svelte.page/docs/examples/sessions - [Getting Started](https://memory.svelte.page/docs/getting-started.md) — https://memory.svelte.page/docs/getting-started # Links - Homepage: - Repository: - NPM: - Issues: