Skip to content

Instantly share code, notes, and snippets.

Created May 13, 2010 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/400261 to your computer and use it in GitHub Desktop.
Save anonymous/400261 to your computer and use it in GitHub Desktop.
var sys = require("sys");
var redis = require("./lib/redis-client");
var redisConn = redis.createClient(redis.DEFAULT_PORT, redis.DEFAULT_HOST, { maxReconnectionAttempts: 15 })
.addListener("connected", function () {
sys.debug("Connected to REDIS");
redisConn.hmset("7qs"
, "created", 1273777131970
, "hits", 0
, "feedId", "7q0"
, "desc", "Enter a description"
, "template", '<div style="border:1px solid black; width:250px; height:250px; overflow:auto;">\n<%\nfor (var i = 0; i < data.length; i++) {\n %><a href="<%= data[i].url %>" style="text-decoration:none;"><%= data[i].tracker %></a>: <font style="color:<%= (data[i].status == "Open") ? "green" : "red" %>;"><%= data[i].status %></font><br/>\n<%\n}\n%></div>'
, "code", 'function anonymous(data) {\n\tvar __output = [];\n\tvar print = function () {\n\t\t__output.push.apply(__output, arguments);\n\t};\n\tprint("<div style=\\"border:1px solid black; width:250px; height:250px; overflow:auto;\\">\\n");\n\t\nfor (var i = 0; i < data.length; i++) {\n \tprint("<a href=\\"");\n\tprint( data[i].url );\n\tprint("\\" style=\\"text-decoration:none;\\">");\n\tprint( data[i].tracker );\n\tprint("</a>: <font style=\\"color:");\n\tprint( (data[i].status == "Open") ? "green" : "red" );\n\tprint(";\\">");\n\tprint( data[i].status );\n\tprint("</font><br/>\\n");\n\t\n}\n\tprint("</div>");\n\treturn(__output.join(\'\'));\n}'
, function (error, result) {
sys.debug(sys.inspect({ error: error, result: result }, false, null));
});
})
.addListener("noconnection", function () {
sys.error("Connection to Redis failed. Not attempting reconnection.");
})
.addListener("reconnecting", function () {
sys.error("Attempting to reconnect REDIS");
})
.addListener("reconnected", function () {
sys.error("Reconnected to REDIS");
})
.addListener("drained", function () {
sys.error("All REDIS commands completed");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment