{"id":44472,"library":"cache-flow","title":"Cache Flow","description":"Cache Flow (v1.10.0) is a Node.js caching library with in-memory and Redis support, featuring automatic cache loading, fallback on Redis disconnection, and a TypeScript @Cacheable decorator. It simplifies caching by eliminating manual get-then-set patterns: you define a CacheLoader with a load method, and calling get() auto-populates and returns cached values. Compared to node-cache or ioredis manually, it offers integrated decorator support, dependency injection compatibility, and configurable serialization. Released under ISC license, last updated in 2022, with moderate release cadence.","status":"maintenance","version":"1.10.0","language":"javascript","source_language":"en","source_url":"https://github.com/abourdin/cache-flow","tags":["javascript","cache","cache-loader","redis","lru","in-memory","node","typescript","di"],"install":[{"cmd":"npm install cache-flow","lang":"bash","label":"npm"},{"cmd":"yarn add cache-flow","lang":"bash","label":"yarn"},{"cmd":"pnpm add cache-flow","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for @Cacheable decorator to work in TypeScript","package":"reflect-metadata","optional":true},{"reason":"Required for Redis cache backend","package":"ioredis","optional":true}],"imports":[{"note":"In TypeScript/ESM, use named import. In CommonJS, require works but types are limited.","wrong":"const CacheLoader = require('cache-flow').CacheLoader","symbol":"CacheLoader","correct":"import { CacheLoader } from 'cache-flow'"},{"note":"Decorator name is 'Cacheable', not '@Cacheable'. The '@' is part of TypeScript decorator syntax, not the import.","wrong":"import { @Cacheable } from 'cache-flow'","symbol":"@Cacheable","correct":"import { Cacheable } from 'cache-flow'"},{"note":"CacheFlow is a named export, not a default export.","wrong":"import CacheFlow from 'cache-flow'","symbol":"CacheFlow","correct":"import { CacheFlow } from 'cache-flow'"}],"quickstart":{"code":"// File: MyCache.ts\nimport { CacheLoader } from 'cache-flow';\nimport 'reflect-metadata';\n\nexport class MyCache extends CacheLoader<string, string> {\n  constructor() {\n    super('my-cache', { expirationTime: 60 }); // 60 seconds\n  }\n\n  protected async load(key: string): Promise<string> {\n    // Simulate fetching data (e.g., from DB)\n    return `value-for-${key}`;\n  }\n}\n\n// File: app.ts\nimport { MyCache } from './MyCache';\n\nconst cache = new MyCache();\nasync function main() {\n  const val1 = await cache.get('foo');\n  console.log(val1); // 'value-for-foo'\n  const val2 = await cache.get('foo');\n  console.log(val1 === val2); // true, cached\n}\nmain();","lang":"typescript","description":"Shows defining a CacheLoader subclass with automatic loading and caching of values."},"warnings":[{"fix":"Always declare load as async or return a Promise.","message":"CacheLoader's load method must return a Promise (or be async) even if synchronous; otherwise get() may not wait for resolution.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Add 'import \"reflect-metadata\";' at the very top of your main file.","message":"In TypeScript, reflection metadata must be imported at the top of the entry file before any CacheLoader subclass is defined.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Enable 'experimentalDecorators' in tsconfig.json.","message":"The @Cacheable decorator is only supported with TypeScript and the experimentalDecorators compiler option.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure in-memory fallback behavior is desired; no explicit fix needed, but be aware that data may be stale if Redis reconnects.","message":"When using Redis, if Redis disconnects, the cache falls back to in-memory, but configuration may still refer to Redis settings.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2022':86 'auto':54 'auto-popul':53 'automat':19 'cach':1,3,9,20,33,58,64,92,94 'cache-load':93 'cacheabl':29 'cacheload':45 'cadenc':90 'call':51 'compar':60 'compat':75 'configur':77 'decor':30,71 'defin':43 'depend':73 'di':103 'disconnect':25 'elimin':35 'fallback':22 'featur':18 'flow':2,4 'get':38,52 'get-then-set':37 'in-memori':12,98 'inject':74 'integr':70 'ioredi':66 'isc':81 'javascript':91 'last':83 'librari':10 'licens':82 'load':21,48 'loader':95 'lru':97 'manual':36,67 'memori':14,100 'method':49 'moder':88 'node':63,101 'node-cach':62 'node.js':8 'offer':69 'pattern':41 'popul':55 'redi':16,24,96 'releas':79,89 'return':57 'serial':78 'set':40 'simplifi':32 'support':17,72 'typescript':28,102 'updat':84 'v1.10.0':5 'valu':59","created_at":"2026-06-07T12:50:18.896232+00:00","updated_at":"2026-06-07T12:50:18.896232+00:00","problems":[{"fix":"Ensure CacheLoader<K, V> is used as a base class in 'class MyCache extends CacheLoader<K, V>'.","cause":"Using CacheLoader as a generic type parameter instead of instantiating it.","error":"Cannot use a namespace name as a generic type parameter. ... 'CacheLoader' refers to a type but is being used as a value here."},{"fix":"Add 'import \"reflect-metadata\";' at the top of your entry file.","cause":"reflect-metadata is not imported or not loaded before cache-flow.","error":"Reflect.defineMetadata is not a function"},{"fix":"If not using Redis, ensure your configuration doesn't reference Redis; otherwise install ioredis.","cause":"ioredis not installed even though it's optional.","error":"Cannot find module 'ioredis' or its corresponding type declarations."}],"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":"https://abourdin.github.io/cache-flow/","github":"https://github.com/abourdin/cache-flow","docs":null,"changelog":null,"pypi":null,"npm":"cache-flow","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage","devops"],"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}}