1.4.3 • Published 7 years ago
redleaf v1.4.3
RedLeaf
Installation
npm install redleaf
Usage
import redleaf from 'redleaf';
ZList
create a sorted set
Param | Type | Description |
---|---|---|
key | String | key of the list |
server | ioredis | server instance of ioredis |
import { ZList } from 'redleaf';
import Redis from 'ioredis';
const redisServer = new Redis();
const list = new ZList('listKey', redisServer)
list.add({ score, member }) => Promise<0|1>
Param | Type | Description |
---|---|---|
score | Number | score of member |
member | String | value to add on list |
list.add({
member: 'one',
score: 1,
})
list.add({
member: 'two',
score: 2,
})
score(member) => Promise< Number >
Param | Type | Description |
---|---|---|
member | String | value to ask for its score |
list.score('one') // 1
list.scrose('three') // -1
remove(member) => Promise<1|2>
Param | Type | Description |
---|---|---|
member | String | value to remove from set |
list.remove('one') // 1
list.remove('four') // 0
scan(cursor) => Promise< {pointer: String, data: [{ member, score }] } >
Param | Type | Description |
---|---|---|
cursor | String | to iterate over set |
rangeByScore(ops) => Promise<[{ member, score }]>
Param | Type | Default | Description |
---|---|---|---|
ops | String | {} | |
ops.range | String | {} | range to get the items |
ops.range.min | String | "-inf" | score minimun to get items |
ops.range.max | String | "+inf" | score maximun to get items |
ops.limit | String | ammount max to bring on request | |
ops.reverse | Boolean | false | to use ZREVRANGEBYSCORE or not |
list.rangeByScore() // [ {member: 'one', score: 1 }, { member: 'two', score: 2 }]
list.rangeByScore({
range: {
min: 1,
max: 5
},
limit: 1,
reverse: true
}); // [ { member: 'two', score: 2 }]
Features to have
License: MIT
1.4.3
7 years ago
1.4.2
7 years ago
1.4.1
7 years ago
1.4.0
7 years ago
1.3.3
7 years ago
1.3.2
7 years ago
1.3.1
7 years ago
1.3.0
7 years ago
1.2.4
8 years ago
1.2.3
8 years ago
1.2.2
8 years ago
1.2.1
8 years ago
1.2.0
8 years ago
1.1.6
8 years ago
1.1.5
8 years ago
1.1.1
8 years ago
1.1.0
8 years ago
1.0.2
8 years ago
1.0.1
8 years ago
0.0.1
8 years ago