Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions gitbook-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ $schema: https://api.gitbook.com/gitbook-docs.yaml
site:
title: RunCache
structure:
- type: space
key: space-v1-7
title: "v1.7 (latest)"
path: v1-7
default: true
content:
directory: ./gitbook-versions/v1.7
language: en
- type: space
key: space-v1-6
title: "v1.6 (latest)"
title: "v1.6"
path: v1-6
default: true
content:
directory: ./gitbook-versions/v1.6
language: en
Expand Down
5 changes: 5 additions & 0 deletions gitbook-versions/v1.7/.gitbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root: ./

structure:
readme: README.md
summary: SUMMARY.md
64 changes: 64 additions & 0 deletions gitbook-versions/v1.7/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# RunCache

{% hint style="info" %}
These docs are for **RunCache v1.7.x** (last updated at release v1.7.0). Install this version with `npm install run-cache@1.7`, or pick another version from the menu above the sidebar.
{% endhint %}

> A dependency-free, lightweight runtime caching library for JavaScript and TypeScript applications.


RunCache allows you to cache strings and other JSON-serializable values with configurable time-to-live (TTL) settings and supports automatic value regeneration through source functions. It's designed to be easy to use while providing powerful features for advanced caching scenarios.

## Key Features

- **Zero Dependencies:** Lightweight implementation with no external dependencies
- **In-Memory Performance:** Fast, efficient runtime cache for optimal application performance
- **Source Function Support:** Cache values generated from synchronous or asynchronous functions
- **Automatic Refetching:** Configure cache entries to automatically refresh on expiration
- **Comprehensive Event System:** Subscribe to cache events including expiry, refetch, and refetch failures
- **Pattern Matching:** Use wildcard patterns to operate on groups of related cache keys
- **Eviction Policies:** Configure size limits with LRU (Least Recently Used) or LFU (Least Frequently Used) eviction strategies
- **Middleware Support:** Add custom processing for intercepting and transforming cache operations
- **Tag-based Invalidation:** Group related cache entries with tags for efficient batch invalidation
- **Dependency Tracking:** Establish relationships between cache entries with automatic cascading invalidation
- **Persistent Storage:** Store cache data across application restarts using various storage adapters
- **TypeScript Support:** Full type definitions included

## Quick Example

```typescript
import { RunCache } from "run-cache";

// Basic caching
await RunCache.set({ key: "user-profile", value: { name: "John Doe" } });
const profile = await RunCache.get("user-profile");

// Cache with expiration (TTL in milliseconds)
await RunCache.set({
key: "api-data",
value: { data: [1, 2, 3] },
ttl: 60000 // 1 minute
});

// Cache with automatic refresh
await RunCache.set({
key: "weather-data",
sourceFn: async () => await fetchWeatherData(),
ttl: 300000, // 5 minutes
autoRefetch: true
});
```

## When to Use RunCache

RunCache is ideal for:

- Caching API responses to reduce network requests
- Storing computed values to improve application performance
- Managing temporary data with automatic expiration
- Creating relationships between cached data with dependencies
- Implementing complex caching strategies with middleware

## Getting Started

To get started with RunCache, check out the [Installation](getting-started/installation.md) guide.
44 changes: 44 additions & 0 deletions gitbook-versions/v1.7/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Table of contents

* [Introduction](README.md)

## Getting Started
* [Installation](getting-started/installation.md)
* [Basic Usage](getting-started/basic-usage.md)
* [Typed Caching](getting-started/typed-caching.md)

## Core Features
* [Cache Management](features/cache-management.md)
* [TTL and Expiration](features/ttl-expiration.md)
* [Automatic Refetching](features/auto-refetch.md)
* [Source Functions](features/source-functions.md)
* [Eviction Policies](features/eviction-policies.md)
* [Pattern Matching](features/pattern-matching.md)

## Advanced Features
* [Tag-based Invalidation](advanced/tag-invalidation.md)
* [Dependency Tracking](advanced/dependency-tracking.md)
* [Event System](advanced/event-system.md)
* [Middleware](advanced/middleware.md)
* [Persistent Storage](advanced/persistent-storage.md)
* [Resource Management](advanced/resource-management.md)
* [Value Serialization](advanced/serialization-adapters.md)
* [Type Safety](advanced/type-validation.md)

## API Reference
* [RunCache](api/run-cache.md)
* [Storage Adapters](api/storage-adapters.md)
* [Events](api/events.md)
* [Types](api/types.md)
* [Typed Cache Interface](api/typed-cache-interface.md)

## Guides
* [Best Practices](guides/best-practices.md)
* [Performance Optimization](guides/performance.md)
* [Debugging and Logging](guides/debugging.md)
* [Migration Guide](guides/migration-guide.md)

## Resources
* [FAQ](resources/faq.md)
* [Contributing](resources/contributing.md)
* [License](resources/license.md)
Loading