Skip to content

bredele/list-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

list-redis

Create a list of hashes sorted by id backend by redis (useful to create queues with data).

Installation

nodejs:

$ npm install list-redis

API

var list = require('list-redis');
var queue = list('mylist');

All functions take either an args Array plus optional callback because operations with redis are asynchronous.

.add(hash, callback)

Create new hash in list and return its id.

queue.add({
  name: 'bredele'
}, function(err, id) {
  //do something
})

Hashes are optional:

queue.add(function(err, id) {
  //do something
})

.get(id, callback)

Get hash by id.

queue.get(12, function(err, hash) {
  //do something
});

.has(id, callback)

Return true if list set exists.

queue.has(12, function(err, exists) {
  //do something
});

.del(id, callback)

Delete list set.

queue.del(12, function(err) {
  //do something
});

Delete list set and hash:

queue.del(12, true, function(err) {
 //do something
});

.move(id, list, callback)

Atomically removes the set of the list stored at source, and pushes the set to the list stored at destination.

var other = list('otherList');
queue.move(12, other, function(){
  //do something optional
});

About

Queue of hashes sorted by id and backend by redis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published