New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@strav/cache

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@strav/cache

Strav cache layer — Cache abstraction + MemoryCache (in-process) + PostgresCache (cross-process ledger) + RedisCache (Bun.RedisClient, all data structures incl. tagged sets) + MemcachedCache (text-protocol client over Bun.connect). Atomic increments, dist

latest
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

@strav/cache

Key/value cache with TTLs for Strav 1.0. Apps inject the abstract Cache token; the provider in the container picks the concrete driver — MemoryCache for single-node dev, PostgresCache for multi-node deployments. Same dependency shape as @strav/broadcast (kernel-free core in the root, optional Postgres driver under a subpath).

import { Cache } from '@strav/cache'

@inject()
class LeadsService {
  constructor(private readonly cache: Cache) {}

  async trending(): Promise<Lead[]> {
    return this.cache.remember('leads.trending', '5m', async () => {
      return this.leads.query().orderBy('score', 'desc').limit(10).get()
    })
  }
}

Canonical docs live in docs/cache/README.md.

What ships

DriverSubpathNotes
Memory@strav/cache (root) + @strav/cache/memoryIn-process. Bounded buffer; locks + tags first-class. Single-node only.
Postgres@strav/cache/postgresCross-process backplane via three tables (strav_cache, strav_cache_locks, strav_cache_tags). Atomic increments via row locks, FK cascade keeps tag rows tight.

The full Cache surface (get/put/forget/has/flush/add/increment/decrement/remember/rememberForever/lock/tags) ships on both drivers; the abstract base provides remember + rememberForever so every driver behaves identically there. No Redis driver yet — apps that need one write against the Cache contract (two abstract methods + the wrapper classes for locks/tags).

FAQs

Package last updated on 01 Jun 2026

Related posts