Permalink
Browse files

Clean up

  • Loading branch information...
1 parent 1ced9f9 commit eef3b7b52f54ecc1c6e870ec2fea68a5286ef920 Igor Urminček committed Jul 30, 2010
Showing with 1 addition and 171 deletions.
  1. +1 −0 .gitignore
  2. +0 −171 redis2json.js
View
1 .gitignore
@@ -0,0 +1 @@
+.DS_Store
View
171 redis2json.js
@@ -50,37 +50,6 @@ var variables = {
// postId: 1
}
-/*
-
-async.parallel([
- loadRedis("text", "post:2:text"),
- function(callback){
- setTimeout(function(){
- callback(null, 'two');
- }, 100);
- },
-],
-// optional callback
-function(err, results){
- sys.debug("Result: " + sys.inspect(results));
-});
- */
-/*
-async.waterfall([
- function(callback){
- callback(null, 'one', 'two');
- },
- function(arg1, arg2, callback){
- callback(null, 'three');
- },
- function(arg1, callback){
- // arg1 now equals 'three'
- callback(null, arg1);
- }
-], function(err, results){
- sys.debug("waterfall Result: " + sys.inspect(results));
-});*/
-
function loadValue(key, redisKey, variables) {
return function (callback) {
@@ -240,145 +209,5 @@ load(map, variables, function (error, result) {
sys.debug(sys.inspect(map));
-
-function loadRedisOld(key, redisKey) {
- return function(callback) {
- redis.get(redisKey, function (error, value) {
-
- sys.debug("redis loaded key " + redisKey + ": " + value);
- callback(value);
- });
- }
-}
-
-function loadRedis(key, redisKey) {
- return function(callback) {
- redis.get(redisKey, function (error, value) {
- sys.debug("redis loaded key " + redisKey + ": " + value);
- var o = {};
- o[key] = value;
- redislib.convertMultiBulkBuffersToUTF8Strings(o);
- callback(error, o);
- });
- }
-}
-
-// loadRedis("text", "post:2:text")(function(obj){
-// sys.debug("OBJ: " + sys.inspect(obj));
-// });
-
-
-function loadString(key, redisKey, variables) {
- return function(callback) {
- return loadRedis(key, fillVariables(redisKey, variables))(callback);
- }
-}
-
-// loadString("text", "post:{postId}:text", {postId: 3})(function(obj){
-// sys.debug("SSSSSS: " + sys.inspect(obj));
-// });
-
-
-function loadObject2(map, variables) {
- return function(callback) {
- var actions = [];
- for (var prop in map) {
- if (map.hasOwnProperty(prop)) {
- if (typeof map[prop] === "string") {
- actions.push(loadString(prop, map[prop], variables));
- }
- }
- }
- Do.parallel(actions)(function (values) {
- var object = {};
- var vars = {};
- for (var i=0; i < values.length; i++) {
- for (prop in values[i]) {
- if (prop.substr(0, 1) == "$") {
- vars[prop.substr(1)] = values[i][prop];
- } else {
- object[prop] = values[i][prop];
- }
-
- }
- };
- callback({object: object, vars: vars});
- // sys.debug("STRINGS: " + sys.inspect(obj));
- });
- }
-}
-
-
-function loadData(map, variables, callback) {
- var keys = [];
- var actions = [];
-
- var strings = [];
- for(var prop in map) {
- if(map.hasOwnProperty(prop)) {
- if (typeof map[prop] === "string") {
- strings.push();
- actions.push(loadRedis(prop, fillVariables(map[prop], variables)));
- }
- }
- }
- // loadStrings();
-}
-
-function nieco() {
- function load(op, key) {
- redis[op](key, function (error, value) {
- // sys.debug(key + ": " + value);
- });
- }
-
- var keys = [];
- var actions = [];
- var result = o || {};
- for(var prop in map) {
- if(map.hasOwnProperty(prop)) {
- if (typeof map[prop] === "string") {
- keys.push(prop);
- actions.push(loadRedis(prop, fillVariables(map[prop], variables)));
- } else if (typeof map[prop] === "object") {
- // loadData(map[prop], variables);
- }
- }
- }
-
- Do.parallel(actions)(function (values) {
- redislib.convertMultiBulkBuffersToUTF8Strings(values);
- sys.debug("Keys: " + sys.inspect(keys));
- sys.debug("Values: " + sys.inspect(values));
- for (var i=0; i < keys.length; i++) {
- sys.debug("$: " + keys[i].substr(0, 1));
- if (keys[i].substr(0, 1) == "$") {
- variables[keys[i].substr(1)] = values[i];
- } else {
- result[keys[i]] = values[i];
- }
- };
-
- sys.debug("Result: " + sys.inspect(result));
- sys.debug("Variables: " + sys.inspect(variables));
-
-
-
- for(var prop in map) {
- if(map.hasOwnProperty(prop)) {
- if (typeof map[prop] === "object") {
- result[prop] = {};
- loadData(map[prop], variables, result[prop]);
- }
- }
- }
-
-
-
-
- });
-
-}
-
sys.debug("Done");

0 comments on commit eef3b7b

Please sign in to comment.