/
RedisIdToSet.js
46 lines (34 loc) · 944 Bytes
/
RedisIdToSet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const Collection = require('../Collection')
class RedisIdToSet extends Collection {
constructor(context) {
super(context, 1)
}
exists(id) {
return ['redis', 'exists', this.toKey(id)]
}
contains(id, value) {
return ['redis', 'sismember', this.toKey(id), value]
}
getList(id) {
return ['redis', 'smembers', this.toKey(id)]
}
iterateList(id) {
return ['redis', 'iterate', 'sscan', this.toKey(id), 0, 'count', 100]
}
add(id, value) {
return ['redis', 'sadd', this.toKey(id), value]
}
addAll(id, values) {
return ['redis', 'sadd', this.toKey(id)].concat(values)
}
remove(id, value) {
return ['redis', 'srem', this.toKey(id), value]
}
clear(id) {
return ['redis', 'del', this.toKey(id)]
}
findKeys() {
return ['redis', 'keys' , this.toKey('*')]
}
}
module.exports = RedisIdToSet