1.0.11 • Published 6 years ago

keyv-mongo-gridfs v1.0.11

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

keyv-mongo-gridfs

MongoDB storage adapter for Keyv with GridFS support

Build Status

MongoDB storage adapter for Keyv.

This adapter is written to support Mongodb GridFS. It stores all values in MongoDB GridFS. Values can be either string, buffer or json serializable objects.

Uses TTL indexes to automatically remove expired documents. However, TTL is not natively supported for GridFS by MongoDB so TTL is implemented with clearExpired() function by this library. You use setInterval on clearExpired() function to automatically remove expired files from GridFS. You decide the interval at which you want to run it.

This module also provides clearUnusedFor(seconds) method to clear files which not accessed for certain files. For example if you want to clear files not used in last 1 day, you can run clearUnusedFor(86400).

Install

npm install --save keyv keyv-mongo-gridfs

Usage

const Keyv = require('keyv');

const keyv = new Keyv('mongodb://user:pass@localhost:27017');
keyv.on('error', handleConnectionError);

You can specify the database name, by default 'keyv-file-cache' is used.

e.g:

const keyv = new Keyv('mongodb://user:pass@localhost:27017', { db: 'example-keyv-cache', readPreference: "primary" });

License

MIT © Aditya Patadia

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

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