ts-cacheable (v1.0.19) is a TypeScript library providing decorators for caching Observable and Promise return values from class methods. It uses an in-memory cache by default and supports configurable cache busting, parameter-based cache keys, max age, sliding expiration, and async resolution. The library was originally designed for Angular (as ngx-cacheable) but is now platform-agnostic. It ships with TypeScript type definitions. Release cadence is low; last release was in 2021.
npm install ts-cacheableNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows Cacheable decorator on Observable-returning methods with in-memory caching and parameter-based cache keys.
Replace all imports from 'ngx-cacheable' with 'ts-cacheable'.
Use 'Cacheable' for Observable, 'PCacheable' for Promise. The old 'Cacheable' works for both but is less explicit.
Use PCacheable for Promise-returning methods instead of Cacheable.
Set "experimentalDecorators": true in tsconfig.json.
If persistence is needed, implement a custom storage strategy using the cacheHasher and ICachePair interface.
Clear any persisted in-memory caches after upgrade; they will be rebuilt.
Test thoroughly and consider using cacheResolver instead for custom cache logic.
Set "experimentalDecorators": true in tsconfig.json and restart the TS server.
Ensure the class is instantiated properly, or use the decorator only on methods within an Angular service or similar DI context.
Use PCacheable decorator for Promise-returning methods.
Run 'npm install ts-cacheable' and ensure tsconfig.json includes node_modules in paths or types.
Avoid calling the same cached method inside itself; use cacheBusterObserver to break recursion.