DEV Community

Cover image for I built a client-side cache in Rust and compiled it to WebAssembly
JohnMark Banisilon
JohnMark Banisilon

Posted on

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

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')
Enter fullscreen mode Exit fullscreen mode

Top comments (0)