moved RedisDB.js to src/redis.js

v1.18.x
psychobunny 12 years ago
parent f7690896cc
commit efa0649081

@ -1,59 +0,0 @@
(function(RedisDB) {
var PRODUCTION = false,
ERROR_LOGS = true,
redis = require('redis'),
db = redis.createClient();
// todo (holy cow): append,auth,bgrewriteaof,bgsave,bitcount,bitop,blpop,brpop,brpoplpush,client kill,client list,client getname,client setname,config get,config set,config resetstat,dbsize,debug object,debug segfault,decrby,del,discard,dump,echo,eval,evalsha,exec,exists,expire,expireat,flushall,flushdb,getbit,getrange,getset,hdel,hexists,hget,hgetall,hincrby,hincrbyfloat,hkeys,hlen,hmget,hmset,hset,hsetnx,hvals,incrby,incrbyfloat,info,keys,lastsave,lindex,linsert,llen,lpop,lpush,lpushx,lrange,lrem,lset,ltrim,mget,migrate,monitor,move,mset,msetnx,multi,object,persist,pexpire,pexpireat,ping,psetex,psubscribe,pttl,publish,punsubscribe,quit,randomkey,rename,renamenx,restore,rpop,rpoplpush,rpush,rpushx,sadd,save,scard,script exists,script flush,script kill,script load,sdiff,sdiffstore,select,setbit,setex,setnx,setrange,shutdown,sinter,sinterstore,sismember,slaveof,slowlog,smembers,smove,sort,spop,srandmember,srem,strlen,subscribe,sunion,sunionstore,sync,time,ttl,type,unsubscribe,unwatch,watch,zadd,zcard,zcount,zincrby,zinterstore,zrange,zrangebyscore,zrank,zrem,zremrangebyrank,zremrangebyscore,zrevrange,zrevrangebyscore,zrevrank,zscore,zunionstore
// done :^) get, set, incr, decr
function return_handler(error, data, callback, error_handler) {
if (error !== null) {
if (error_handler !== null) {
error_handler(error);
} else if (PRODUCTION === false) {
throw new Exception('RedisDB Error: ' + error);
} else if (ERROR_LOGS === true) {
console.log('RedisDB Error: ' + error);
}
} else {
callback(data);
}
}
RedisDB.set = function(key, value) {
db.set(key, value);
};
RedisDB.get = function(key, callback, error_handler) {
db.get(key, function(error, data) {
return_handler(error, data, callback, error_handler);
});
};
// Atomic Operations
RedisDB.incr = function(key, callback, error_handler) {
db.incr(key, function(error, data) {
if (callback) {
return_handler(error, data, callback, error_handler);
}
});
};
RedisDB.decr = function(key) {
db.decr(key);
};
// Lists
RedisDB.lpush = function(key, item) {
db.lpush(key, item);
}
RedisDB.lrange = function(key, start, end, callback, error_handler) {
db.lrange(key, start, end, function(error, data) {
return_handler(error, data, callback, error_handler);
});
}
}(exports));

@ -1,4 +1,4 @@
var RDB = require('../RedisDB.js');
var RDB = require('./redis.js');
(function(User) {
var current_uid;
@ -26,11 +26,11 @@ var RDB = require('../RedisDB.js');
RDB.set('uid:' + uid + ':password', password);
RDB.incr('user:count', function(count) {
global.io.sockets.emit('user.count', {count: count});
io.sockets.emit('user.count', {count: count});
});
RDB.lpush('user:users', username);
global.io.sockets.emit('user.latest', {username: username});
io.sockets.emit('user.latest', {username: username});
global.socket.emit('user.create', {'status': 1});
});

Loading…
Cancel
Save