{"id":44519,"library":"cachette","title":"cachette","description":"A resilient caching library for Node.js (version 6.0.2, latest) that supports concurrent requests through local in-memory cache or Redis. Designed for internal use at Unito, it is undocumented but ships with TypeScript source code. Key differentiators include built-in concurrency handling to avoid thundering herd problems, a simple WriteThroughCache interface, and support for custom TTLs. Requires Node >=20 and npm >=10. Not recommended for production use outside of Unito due to lack of documentation and potential instability.","status":"maintenance","version":"6.0.2","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript","cache","concurrent","redis","decorator"],"install":[{"cmd":"npm install cachette","lang":"bash","label":"npm"},{"cmd":"yarn add cachette","lang":"bash","label":"yarn"},{"cmd":"pnpm add cachette","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"optional Redis backend; if not provided, falls back to local cache","package":"redis","optional":true}],"imports":[{"note":"ESM imports are preferred, but CommonJS require also works (library provides both ESM and CJS). TypeScript types are bundled.","wrong":"const { WriteThroughCache } = require('cachette')","symbol":"WriteThroughCache","correct":"import { WriteThroughCache } from 'cachette'"},{"note":"Cachette is a named export. CommonJS require would need { Cachette }.","wrong":"const Cachette = require('cachette')","symbol":"Cachette","correct":"import { Cachette } from 'cachette'"},{"note":"CacheOptions is a TypeScript type, so use 'import type' to avoid runtime errors.","wrong":"import { CacheOptions } from 'cachette'","symbol":"CacheOptions","correct":"import type { CacheOptions } from 'cachette'"}],"quickstart":{"code":"import { WriteThroughCache } from 'cachette';\n\nconst redisUrl = process.env.REDIS_URL ?? '';\nconst cache = new WriteThroughCache(redisUrl);\n\nasync function fetchUrl(url: string): Promise<string> {\n  console.log('fetching', url);\n  const response = await fetch(url);\n  console.log('fetched', url);\n  return response.text();\n}\n\nasync function fetchUrlCached(url: string): Promise<string> {\n  const fetchFunction = () => fetchUrl(url);\n  return cache.getOrFetchValue(url, 600, fetchFunction);\n}\n\nfetchUrlCached('https://example.com').then(() => console.log('first call returned'));\nsetTimeout(() => {\n  fetchUrlCached('https://example.com').then(() => console.log('second call returned'));\n}, 100);","lang":"typescript","description":"This shows how to initialize a WriteThroughCache with a Redis URL, define a fetch function, and use getOrFetchValue to cache results with TTL, demonstrating concurrency handling."},"warnings":[{"fix":"Do not use in production applications unless you are willing to maintain your own fork.","message":"The library is undocumented and intended only for internal Unito use. Expect breaking changes with no warning.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Upgrade to Node.js 20 or later.","message":"Node.js >=20 is required. Older Node versions (18, 16) are not supported.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Always provide a valid Redis URL or catch instantiation errors.","message":"If REDIS_URL is not provided, the WriteThroughCache constructor will fail silently or behave unexpectedly.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"Monitor the changelog for API changes.","message":"getOrFetchValue method may be deprecated in future versions in favor of a more flexible API.","severity":"deprecated","affected_versions":">=6.0.0"}],"env_vars":null,"search_vec":"'10':65 '20':62 '6.0.2':9 'avoid':47 'built':42 'built-in':41 'cach':4,20,84 'cachett':1 'code':37 'concurr':13,44,85 'custom':58 'decor':87 'design':23 'differenti':39 'document':78 'due':74 'handl':45 'herd':49 'in-memori':17 'includ':40 'instabl':81 'interfac':54 'intern':25 'javascript':82 'key':38 'lack':76 'latest':10 'librari':5 'local':16 'memori':19 'node':61 'node.js':7 'npm':64 'outsid':71 'potenti':80 'problem':50 'product':69 'recommend':67 'redi':22,86 'request':14 'requir':60 'resili':3 'ship':33 'simpl':52 'sourc':36 'support':12,56 'thunder':48 'ttls':59 'typescript':35,83 'undocu':31 'unito':28,73 'use':26,70 'version':8 'writethroughcach':53","created_at":"2026-06-07T12:50:31.624803+00:00","updated_at":"2026-06-07T12:50:31.624803+00:00","problems":[{"fix":"const cache = new WriteThroughCache(url);","cause":"Using WriteThroughCache without 'new' keyword.","error":"TypeError: Class constructor WriteThroughCache cannot be invoked without 'new'"},{"fix":"Ensure Redis is running on localhost:6379 or provide a different REDIS_URL.","cause":"Redis server is not running or unreachable.","error":"Error: Redis connection failed: connect ECONNREFUSED 127.0.0.1:6379"},{"fix":"Use version >=6.0.0 and import { WriteThroughCache } from 'cachette'.","cause":"Importing an older version that does not have getOrFetchValue or using a CommonJS import incorrectly.","error":"TypeError: cache.getOrFetchValue is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"cachette","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}