@repositories/redis
v1.0.0
Published
Generic IRepository implementation for Redis
Downloads
269
Maintainers
Readme
Redis Repository
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);
});