4.2.1 • Published 7 years ago

catbox-mongodb v4.2.1

Weekly downloads
155
License
BSD-3-Clause
Repository
github
Last release
7 years ago

catbox-mongodb

MongoDB adapter for catbox

Build Status catbox-mongodb

Lead Maintainer: Marcus Poehls

catbox-mongodb serializes values to BSON using MongoDB driver, therefore following data types are supported for this adapter: Object, Array, Number, String, Date, RegExp.

Installation

The lastest catbox-mongodb version 4.x works only with hapi v17

Install catbox-mongodb via NPM. Remember that catbox-mongodb requires its parent module catbox:

npm install catbox catbox-mongodb

Do you use hapi v16 or lower? Install catbox-mongodb version 3.x with a compatible version of catbox:

# for hapi v16 (or lower)
npm install catbox@9 catbox-mongodb@3

Options

catbox-mongodb accepts the following options:

  • uri - the MongoDB URI, defaults to 'mongodb://127.0.0.1:27017/?maxPoolSize=5'
  • partition - the MongoDB database for cached items

Usage

Sample catbox cache initialization :

const Catbox = require('catbox');

const cache = new Catbox.Client(require('catbox-mongodb'), {
    uri: 'your-mongodb-uri', // Defaults to 'mongodb://127.0.0.1:27017/?maxPoolSize=5' if not provided
    partition: 'cache'
})

Or configure your hapi server to use catbox-mongodb as the caching strategy (code snippet uses hapi v17):

const Hapi = require('hapi')
const CatboxMongoDB = require('catbox-mongodb')

const server = new Hapi.Server({
    cache : [{
        name      : 'mongoDbCache',
        engine    : CatboxMongoDB,
        uri       : 'your-mongodb-uri', // Defaults to 'mongodb://127.0.0.1:27017/?maxPoolSize=5' if not provided
        partition : 'cache'
    }]
});
4.2.1

7 years ago

4.2.0

7 years ago

4.1.0

7 years ago

4.0.0

8 years ago

3.0.1

8 years ago

3.0.0

9 years ago

2.0.0

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

11 years ago

1.0.5

11 years ago

1.0.4

11 years ago

1.0.3

11 years ago

1.0.2

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago