Registry / devops / tweek-local-cache

tweek-local-cache

JSON →
library0.8.0jsnpmunverified

Local caching layer for Tweek feature management client. Provides in-memory caching with configurable TTL to reduce network requests and improve latency when fetching feature toggles from Tweek service. v0.8.0 is current stable; release cadence is irregular. Key differentiator: designed specifically for tweek-client, supports key-value caching with automatic invalidation. Maintained by Soluto. TypeScript definitions included.

npm install tweek-local-cache
INSTALL
IMPORT
SIG · TWEEK-LOCAL-CACHE
T
tweek-local-cache
devopsjavascriptv0.8.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TweekLocalCache
import { TweekLocalCache } from 'tweek-local-cache'
const TweekLocalCache = require('tweek-local-cache');
ESM-only since v0.5; CJS require will cause runtime error. TypeScript types included.
createTweekLocalCache
import { createTweekLocalCache } from 'tweek-local-cache'
import createTweekLocalCache from 'tweek-local-cache';
Default export not available; use named import.
TweekLocalCacheConfig
import { TweekLocalCacheConfig } from 'tweek-local-cache'
Type import; only needed for TypeScript. Not exported in v0.4 and earlier.

Creates a Tweek client with local caching, fetches a feature value.

import { TweekLocalCache } from 'tweek-local-cache'; import { TweekClient } from 'tweek-client'; const cache = new TweekLocalCache({ ttl: 300, // 5 minutes maxEntries: 1000 }); const client = new TweekClient({ baseUrl: 'https://your-tweek-repo.example.com', cache }); async function getFeature() { const value = await client.get('feature-key', { user: 'user-id' }); console.log(value); }
Debug
Known issues
breakingESM-only since v0.5. CommonJS require() no longer supported.
fix
Use import syntax or downgrade to v0.4.
affects: >=0.5
gotchaCache TTL is not reset on get; entries expire exactly TTL seconds after insertion, not after last access.
fix
Set longer TTL or implement custom refresh logic if needed.
affects: >=0.1
gotchamaxEntries is an approximate limit; cache eviction uses FIFO, not LRU.
fix
Set maxEntries conservatively to avoid unexpected evictions.
affects: >=0.1
deprecatedThe 'TweekLocalCache' class constructor with no options is deprecated, will be removed in v1.0.
fix
Provide at least an empty object: new TweekLocalCache({}).
affects: >=0.7
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/to/node_modules/tweek-local-cache/index.js
Using require() in Node.js with ESM-only package v0.5+
fix
Use import { TweekLocalCache } from 'tweek-local-cache' or set type: 'module' in package.json.
TypeError: Cannot read properties of undefined (reading 'get')
Tweek client constructed without providing cache instance but code expects cache to be present
fix
Pass a TweekLocalCache instance as 'cache' option to TweekClient.
Property 'TweekLocalCacheConfig' does not exist on type 'typeof import("tweek-local-cache")'
Attempting to import TweekLocalCacheConfig in v0.4 or earlier where it is not exported
fix
Update to v0.5+ or define the interface manually.
Upgrade
Version history
0.8.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
tweek-local-cache — npm install tweek-local-cache · libregistry