Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
this.userid = profile.id_str;
let creds = userdata.credentials;
// use the application's consumer stuff but the user's access stuff
creds.consumer_key = this.app.get('twitterCredentials').consumer_key;
creds.consumer_secret = this.app.get('twitterCredentials').consumer_secret;
console.log(creds);
this.T = new Twit(creds);
// This user doesn't exist in the DB yet so we create a blank entry
// and include the new keyword and expiration date
// mutedUsers and isExpired are empty because we're intializing
if (!exists) {
console.log(`writing ${profile.id_str} to database...`);
// TODO hash our application credentials???? maybe??
client.hset(`supermute-users`, profile.id_str, JSON.stringify(userdata), redis.print);
// save our userdata to this stream object
this.userdata = userdata;
}
else {
// do nothing
}
// start the stream
this.start(UNMUTE);
});
}
rc.llen(chatEntriesInRoomKey, function(err, len){
if(err){
console.log("Error: while trying to get length of list of messages in '" + chatEntriesInRoomKey + "'. Error msg: " + err);
} else if( len > config.MAX_MESSAGES_IN_BACKLOG + 1 ){
console.log("Found a bunch of extra messages in '" + chatEntriesInRoomKey + "'. Getting rid of the oldest " + (len - config.MAX_MESSAGES_IN_BACKLOG) + " of them.");
rc.ltrim(chatEntriesInRoomKey, (-1 * config.MAX_MESSAGES_IN_BACKLOG), -1, redis.print);
} else if( len == (config.MAX_MESSAGES_IN_BACKLOG + 1)){
// This seems like it'd be faster than ltrim even though ltrim says it's O(N) where N is number to remove and this is O(1).
console.log("Trimming extra entry from list of messages in '" + chatEntriesInRoomKey + "'");
rc.lpop(chatEntriesInRoomKey, redis.print);
}
});
console.log("Done pruning any old messages in room (if needed).");
var redis = require("redis"),
client = redis.createClient();
client.on("error", function (err) {
console.log("error event - " + client.host + ":" + client.port + " - " + err);
});
client.set("string key", "string val", redis.print);
client.hset("hash key", "hashtest 1", "some value", redis.print);
client.hset(["hash key", "hashtest 2", "some other value"], redis.print);
client.hkeys("hash key", function (err, replies) {
if (err) {
return console.error("error response - " + err);
}
console.log(replies.length + " replies:");
replies.forEach(function (reply, i) {
console.log(" " + i + ": " + reply);
});
});
client.quit(function (err, res) {
console.log("Exiting from quit command.");
});
}).then(function({data}) {
console.log(data);
redisClient.set('events', JSON.stringify(data), redis.print);
});
function set(key, val) {
if (typeof val === "object") {
val = JSON.stringify(val);
}
redisClient.set(key, val, redis.print);
}
RedisBackend.prototype.save = function(topic, data) {
if (!topic || !data) return;
var self = this;
var cleanTopic = utils.replaceAll("/", "-", topic);
var key = self.keyPrefix + ":" + cleanTopic + ":" + (new Date).getTime();
self.logger.debug("[%s] %s > %s", self.config.index, cleanTopic, data);
self.client.set(key, data.toString(), redis.print);
};
var NodeCodis = /** @class */ (function (_super) {
__extends(NodeCodis, _super);
function NodeCodis(opts) {
var _this = this;
opts.redisClient = 'redis';
_this = _super.call(this, opts) || this;
return _this;
}
NodeCodis.getRandomClient = function (clientsMap) {
return _super.getRandomClient.call(this, clientsMap);
};
NodeCodis.print = redis.print;
return NodeCodis;
}(BaseCodis));
exports.NodeCodis = NodeCodis;
client.get(cacheKey, function(err, reply) {
if(!!req.query.expireCache && reply) {
client.del(cacheKey, redis.print)
reply = JSON.parse(reply)
reply.cache.expiring = true
reply = JSON.stringify(reply)
}
return callback(err, reply, cacheKey)
})
}