-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.js
58 lines (55 loc) · 1.36 KB
/
index.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
47
48
49
50
51
52
53
54
55
56
57
58
var _ = require('underscore');
var Barn = require('./lib/barn');
function API(namespace, storage, opts){
if (!opts) opts = {};
if(!storage){
storage = namespace;
namespace = 'BARN';
}
this.barn = new Barn(namespace, storage, opts);
}
_.extend(API.prototype, {
get: function(key){
return this.barn.execCmd('GET', key);
},
set: function(key, val){
return this.barn.execCmd('SET', key, val);
},
del: function(key){
return this.barn.execCmd('DEL', key);
},
lpop: function(key){
return this.barn.execCmd('LPOP', key);
},
lpush: function(key, val){
return this.barn.execCmd('LPUSH', key, val);
},
rpop: function(key){
return this.barn.execCmd('RPOP', key);
},
rpush: function(key, val){
return this.barn.execCmd('RPUSH', key, val);
},
llen: function(key){
return this.barn.execCmd('LLEN', key);
},
lrange: function(key, start, end){
return this.barn.execCmd('LRANGE', key, start, end);
},
sadd: function(key, val){
return this.barn.execCmd('SADD', key, val);
},
smembers: function(key){
return this.barn.execCmd('SMEMBERS', key);
},
sismember: function(key, val){
return this.barn.execCmd('SISMEMBER', key, val);
},
srem: function(key, val){
return this.barn.execCmd('SREM', key, val);
},
condense: function(){
return this.barn.condense();
},
});
module.exports = API;