Initial redis example
This commit is contained in:
19
redis/client.js
Normal file
19
redis/client.js
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
const redis = require("redis");
|
||||
|
||||
redisClient = redis.createClient(process.env.REDIS_PORT, process.env.REDIS_HOST);
|
||||
|
||||
redisClient.on("error", function(err) {
|
||||
console.log("Error " + err);
|
||||
});
|
||||
|
||||
redisClient.set("string key", "string val", redis.print);
|
||||
redisClient.hset("hash key", "hashtest 1", "some value", redis.print);
|
||||
redisClient.hset(["hash key", "hashtest 2", "some other value"], redis.print);
|
||||
redisClient.hkeys("hash key", function (err, replies) {
|
||||
console.log(replies.length + " replies:");
|
||||
replies.forEach(function (reply, i) {
|
||||
console.log(" " + i + ": " + reply);
|
||||
});
|
||||
redisClient.quit();
|
||||
});
|
||||
Reference in New Issue
Block a user