keyv-pouchdb
v0.1.0-alpha.2
Published
PouchDB storage adapter for Keyv
Downloads
2
Maintainers
Readme
Motivation
Leveraging pouchdb-lru-cache as a keyv-storage-adapter that complies with the api specs.
Installation
$ npm install --save keyv-pouchdb
# Then add a pouchdb adapter
$ npm install pouchdb-adapter-memory --save
$ npm install pouchdb-adapter-http --save
$ npm install pouchdb-adapter-node-websql --save
Usage
const KeyvPouchDB = require("keyv-pouchdb");
const Keyv = require("keyv");
const store = new KeyvPouchDB({
// default options
maxCacheSize: 5000000, // maximum cache size in bytes. 0 for limitless [memory only]
overwriteExisting: false, // replace existing entries
pouchDB: {
// pouchDB configuration options
adapter: "memory", // pouchdb adapter
database: "keyv-pouchdb-cache", // database (string | uri)
remoteConfig: {} // configuration options for remote database
}
});
/*
* or connect to a remote instance
*
* npx pouchdb-server --port 3000 --in-memory
*
*/
new KeyvPouchDB("http://localhost:3000/keyv-pouchdb-cache"); // loads `pouchdb-adapter-http`
/*
*
* or maybe even sqlite3
*
*/
new KeyvPouchDB("database.db"); // loads `pouchdb-adapter-node-websql`
/****************************/
const keyv = new Keyv({ store });
License
MIT © wmik