TypeScript-based caching decorators to assist with caching (and clearing cache for) async methods. This package supports cache-manager
store engines.
This adapter is a bit different from the others, because it's essentially just giving you the option to use @type-cacheable/core
decorators with store engines (similar to @type-cacheable
's other adapters)
maintained by cache-manager
maintainers and users.
npm install --save @type-cacheable/core @type-cacheable/cache-manager-adapter
See the cache-manager documentation for more information on available store engines.
import { sqliteStore } from '@resolid/cache-manager-sqlite';
import * as cacheManager from 'cache-manager';
import { join } from 'node:path';
import { useAdapter } from '@type-cacheable/cache-manager-adapter';
// An example using the @resolid/cache-manager-sqlite adapter
const store = sqliteStore({
cacheTableName: 'cache',
sqliteFile: join(process.cwd(), 'cache.sqlite3'),
});
const cacheManagerCache = cacheManager.createCache(store);
const clientAdapter = useAdapter(cacheManagerCache);
Then you can rely on the @Cacheable
, @CacheUpdate
, and @CacheClear
decorators from @type-cacheable/core
. See core documentation