Git Product home page Git Product logo

ex.redis's Introduction

ex.redis

Functions for work with redis like mongodb. And sync mongo with redis. This module provide to write, read docs in redis like mongo, use collections and not only string fields.

Usage

You can store JSON object like some one:

{
    str: "some string",
    num: 1,
    subDoc: {
        created : new Date(),
        rules: ['some string', 'some string 2']
    },
    floatValue: 9.9,
    nullValue: null
}

Create redis connection

var redis = require('redis'),
    rc = redis.createClient();

Store document into redis

For example store document into collection test_collection with id 51e512352cb6640403695121

exRedis.write(rc, 'test_collection', '51e512352cb6640403695121', {
    str: "some string",
    num: 1,
    subDoc: {
        created : new Date(),
        rules: ['some string', 'some string 2'],
        testInc: 1
    },
    floatValue: 9.9,
    nullValue: null
}, callback);

Get document

  exRedis.read(rc, 'test_collection', '51e512352cb6640403695121', function(err, doc){});

Get documents list

  exRedis.find(rc, 'test_collection', function(err, documents){});

Remove document from collection

  exRedis.remove(rc, 'test_collection', '51e512352cb6640403695121', function(err){});

Increment for field of document

  exRedis.inc(rc, 'test_collection', '51e512352cb6640403695121', 'subDoc.testInc', 1, function(err){});

Get version of document collection

  exRedis.version(rc, 'test_collection', function(err, version){});

Set version of document collection

  exRedis.setVersion(rc, 'test_collection', versionValue, function(err, version){});

Sync collections between mongo and redis

  exRedis.mongo.sync({
    db: db,                 // Mongo native driver database
    collection: 'test',     // Collection name
    defaultVersion : 10000  // Default value for version of collection data
  },{
    connection: rc,         // Redis driver connection
    collection: 'test',     // Redis collection name
    defaultVersion : 0      // Default value of version of collection data  
  }, function(err, count, fromTo){}); 

count - count of transferred documents

fromTo - side of transfer, may be mongodb -> redis, redis -> mongodb or none if versions is same

ex.redis's People

Contributors

a696385 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.