Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

@keyvhq/mongo 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.

Install

npm install --save @keyvhq/core @keyvhq/mongo

Usage

NOTE: The mongo uses url instead of uri 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