1.0.4 • Published 6 years ago

raincache-mongo v1.0.4

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

RainCache-Mongo

Bringing MongoDB support to @DasWolke's RainCache since 2018

Purpose

Currently, RainCache, though designed to be extensible with other "storage engines", only supports storing data in Redis. This package sets out to provide MongoDB support by creating an easy-to-use MongoStorageEngine.

How to use

Install by running this:

$ npm install raincache-mongo --save

Then initialize RainCache like so:

const RainCache = require("raincache");
const {MongoClient} = require("mongodb");

const {MongoStorageEngine} = require("raincache-mongo");

db.connect().then((client) => {
    let connector = new RainCache.Connectors.AmqpConnector();
    let db = client.db("dbName");
    
    let cache = new RainCache({
        storage: {
            default: new MongoStorageEngine({
                db: db
            })
        }
    }, connector, connector);
});

By default, MongoStorageEngine will store RainCache data in the raincache and raincachelists collections.

Building and Testing

*NOTE: This section is only for those who want to contribute or tinker with raincache-mongo.*

raincache-mongo is written in TypeScript, a superset of JavaScript. As such, it must be compiled down to regular JavaScript whenever changes are made.

Compiling/building raincache-mongo can be done in one command:

$ npm run build

To perform unit testing on raincache-mongo (after you've run npm run build), use:

$ npm test

Building and testing can be combined into a single command, like so:

$ npm run build:test
1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago