TypeScript decorator for memoizing class methods and getters with cache expiration and clearing support. Version 2.1.0, actively maintained. Supports Node.js and browsers. Differentiators: built-in TTL (time-to-live), two-level cache clearing (method-level and instance-level), custom resolver function, and TypeScript-first design. Lower overhead than libraries like lodash.memoize because it uses decorator syntax and integrates with class-based architecture. Can memoize async, static, and getter functions. Requires TypeScript >4.x and experimentalDecorators.
npm install memoize-cache-decoratorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic memoization with TTL, then clearing cache for a specific function and for the entire instance.
Add "experimentalDecorators": true to tsconfig.json, or consider using a different library if you require native ECMAScript decorators.
Update package name from 'memoize-decorator' to 'memoize-cache-decorator' in package.json and imports.
Wrap the function in a class method or use a different memoization approach for standalone functions.
If you need a shared cache across instances, consider using a static method or a different caching strategy.
Ensure your async methods are called after the first promise resolves, or implement a queuing mechanism.
Ensure you are using the decorator inside a TypeScript class (or with proper Babel decorator transform) and that the import is correct.
For Node: npm install memoize-cache-decorator. For Deno: import { memoize } from 'jsr:@edwinm/memoize-decorator@2'Use: import { memoize } from 'memoize-cache-decorator'No dependency data recorded yet.