Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 1019 Bytes

File metadata and controls

46 lines (33 loc) · 1019 Bytes

Redis Repository

NPM version NPM Downloads

Installation

$ npm install --save @repositories/redis

Usage

'use strict';

const redis = require('redis');
const client = redis.createClient();
const RedisRepository = require('@repositories/redis');

class TodoRepository extends RedisRepository {
  constructor(client){
    super(client, 'todos');
  }
  // custom implementations
}

// or if you dont need custom functionality

const repo = new RedisRepository(client, 'todos');

repo.add({ name: 'Tom' }, (err, doc) => {
  console.log(doc);
});
 
// expire after 5 seconds
repo.add({ name: 'Tom' }, { expire: 5 }, (err, doc) => {
  console.log(doc);
});