MongoDB cache store for node-cache-manager. This is a rewrite of v4l3r10/node-cache-manager-mongodb.
npm install @tirke/node-cache-manager-mongodb
yarn add @tirke/node-cache-manager-mongodb
pnpm add @tirke/node-cache-manager-mongodb
import { caching } from 'cache-manager'
import { mongoDbStore } from './node-cache-manager-mongodb'
const mongoCache = await caching(mongoDbStore, {
url: 'mongodb://localhost:27017',
mongoConfig: { auth: { password: '<password>', username: '<user>' } },
})
import { caching } from 'cache-manager'
import { mongoDbStore } from './node-cache-manager-mongodb'
const mongoCache = await caching(mongoDbStore, {
url: 'mongodb://localhost:27017',
mongoConfig: { auth: { password: '<password>', username: '<user>' } },
})
await mongoCache.set('foo', 'bar', { ttl: 5 })
const result = await mongoCache.get('foo')
await mongoCache.del('foo')
import { caching } from 'cache-manager'
import { mongoDbStore } from './node-cache-manager-mongodb'
const mongoCache = await caching(mongoDbStore, {
url: 'mongodb://localhost:27017',
collectionName: 'custom-collection-name',
mongoConfig: { auth: { password: '<password>', username: '<user>' } },
})
import { caching } from 'cache-manager'
import { mongoDbStore } from './node-cache-manager-mongodb'
const mongoCache = await caching(mongoDbStore, {
url: 'mongodb://localhost:27017',
databaseName: 'custom-database-name',
mongoConfig: { auth: { password: '<password>', username: '<user>' } },
})