MongoDB storage adapter for Keyv
npm install @keyv/mongo> MongoDB storage adapter for Keyv




MongoDB storage adapter for Keyv.
Uses TTL indexes to automatically remove expired documents. However MongoDB doesn't guarantee data will be deleted immediately upon expiration, so expiry dates are revalidated in Keyv.
``shell`
npm install --save keyv @keyv/mongo
`js
import Keyv from 'keyv';
import KeyvMongo from '@keyv/mongo';
const keyv = new Keyv(new KeyvMongo('mongodb://user:pass@localhost:27017/dbname'));
keyv.on('error', handleConnectionError);
`
You can specify the collection name, by default 'keyv' is used.
e.g:
`js``
const keyv = new Keyv('mongodb://user:pass@localhost:27017/dbname', { collection: 'cache' });