I built a client-side cache in Rust and compiled it to WebAssembly

2026-11-01来源 dev.to RustEnglish

I built Blaze Cache, a high-performance client-side caching library written in Rust and compiled to WebAssembly.

The goal was simple: make browser caching fast, predictable, and easy to integrate — without turning it into a heavy framework.

Why Wasm?

Most browser caches are pure JavaScript. That works, but I wanted:

  • More predictable performance
  • A cleaner core data structure
  • A single engine that multiple adapters could share

So the hot path (storage, TTL, tags, eviction) runs in Rust → Wasm. After initialization, get and set are fully synchronous.

What it supports

  • Synchronous reads and writes after init
  • SIEVE eviction
  • TTL + tag-based invalidation
  • Optional IndexedDB persistence
  • Typed event system
  • Adapters for:
    • Axios
    • fetch
    • TanStack Query
    • SWR

Example

 ts import { createCache } from '@blaze-cache/core' const cache = await createCache({ capacity: 1000 }) cache.set('user:42', { name: 'Ada' }, { ttlMs: 30_000, tags: ['user'] }) cache.get('user:42') cache.invalidateTags('user') 

原文:https://www.a8q9.cn/en/article/i-built-a-client-side-cache-in-rust-and-compiled-it-to-webassembly-9c4821.html

相关文章