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.
npm install --save @keyvhq/core @keyvhq/mongo
NOTE: The mongo uses
url
instead ofuri
to provide the connection string details.
const KeyvMongo = require('@keyvhq/mongo')
const Keyv = require('@keyvhq/core')
const keyv = new Keyv({
store: new KeyvMongo('mongodb://user:pass@localhost:27017/dbname')
})
You can specify the collection name, by default 'keyv'
is used:
const KeyvMongo = require('@keyvhq/mongo')
const Keyv = require('@keyvhq/core')
const keyv = new Keyv({
store: new KeyvMongo('mongodb://user:pass@localhost:27017/dbname', {
collection: 'cache'
})
})
@keyvhq/mongo © Luke Childs, released under the MIT License.
Maintained by Microlink with help from contributors.
microlink.io · GitHub microlinkhq · X @microlinkhq