Giter Site home page Giter Site logo

redis-dump-restore's Introduction

redis-dump-restore

NPM

NPM

Build Status Coverage Status

This is a library for Node.js to dump and restore Redis contents using DUMP and RESTORE commands.

It issues those commands using the redis npm package. You have to provide instance of the client yourself. Make sure to set return_buffers and/or detect_buffers to true (see docs) so that we get Buffer instances from the client. This is required because otherwise binary data is corrupted. Use 1.0.0+ version of the redis library - previous versions have bugs in detect_buffers handling.

Dependencies

No production-time dependencies. For the list of test-time dependencies and their versions see the package.json file.

Usage

const redis = require('redis');
const dump = require('redis-dump-restore').dump;
// Use this function to DUMP all values atomically (inside MULTI)
//const dump = require('redis-dump-restore').dumpMulti;

const clientInstance = redis.createClient('localhost', 6379, { detect_buffers: true });
const dumpEx = dump(clientInstance, '*');

dumpEx
  .on('data', function (key, data, ttl) {
    // Do something with data.
    // Both key and data are Buffers with binary data.
    // ttl is 0 if key expiration is not set, otherwise it is a positive value in milliseconds.
  })
  .on('error', function (err) {
    // Handle error
   })
  .on('end', function () {
    // We're done!
  });

To restore a dump just use the redis client's restore command for each saved key. You can do that as a single transaction if needed using MULTI.

Install instructions

In your project directory run the following command to add this library as a dependency:

npm install redis-dump-restore --save

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.