An open API service indexing awesome lists of open source software.

https://github.com/mikeal/redcouch

A client that stores data in both CouchDB and Redis.
https://github.com/mikeal/redcouch

Last synced: 5 days ago
JSON representation

A client that stores data in both CouchDB and Redis.

Awesome Lists containing this project

README

        

# redcouch -- A client that stores data in both CouchDB and Redis.

## Install


npm install redcouch

Or from source:


git clone git://github.com/mikeal/redcouch.git
cd redcouch
npm link

## Usage

```javascript
var redcouch = require('redcouch')
, red = redcouch('http://localhost:5984/shortened')
;

red.set('key', 'value', function (e) {
if (e) throw e
red.get('key', function (e, value) {
if (e) throw e
console.error(value) // "value"
red.close()
})
})
```

## redcouch(couchurl,[redisoptions])

By default redcouch will connect to a localhost Redis on the default port.

Available Redis options are: `host`, `port`, and `select`. The `select` option will insure that redcouch uses the specified numeric DB.

## red.prime([clobber], cb)

Fills the Redis database with all the key/value pairs from the Couch database.

```
var redcouch = require('redcouch')
, red = redcouch('http://localhost:5984/shortened')
;
red.prime(function (e) {
if (e) throw e
console.log('finished')
red.close()
})
```

Clobber will remove all Redis keys that are not in the Couch database.

## red.close()

Must be called in order to shutdown the redis connections as they are persistent.

## red.ensureWrite = false

Defaults to false. When set to false set callbacks will be resolved after the key is stored in Redis, if set to true they will not be resolved until they are set in Couch.

## red.redis

Redis client, uses @mranney's wonderful node-redis library.

## red.couch

Couch client, uses @mikeal's couch library.