@keyvhq/mongo
v2.1.5
Published
MongoDB storage adapter for Keyv
Downloads
147
Readme
@keyvhq/mongo
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.
Install
npm install --save @keyvhq/core @keyvhq/mongo
Usage
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'
})
})
License
@keyvhq/mongo © Luke Childs, released under the MIT License. Maintained by Microlink with help from contributors.
microlink.io · GitHub microlinkhq · X @microlinkhq