Examples

  • Single value

    • Initiate the 1st value for the list.

      var data = {
              "variable": "list1",
              "value": "Hello"
              };
      
      redis.set(data);
  • Hash datatype

    • Insert the hash object {"hkey1":"hval1", ...} to a new variable hash1.

      
      redis.set({"variable": "hash1", "value": {"hkey1":"val1", "hkey2":"val2", "hkey3":"val3"}});
  • List datatype

    • Insert the (repeating and unsorted) array ["lval1", "lval2", "lval3", "lval4"] to the head of an existed variable list1.

      var data = {
              "variable": "list1",
              "value": ["lval1", "lval2", "lval3", "lval4"],
              "index": [0],
              };
      
      redis.add(data);
  • Set datatype

    • Insert the (none-repeating and unsorted) array ["sval1", "sval2", "sval3"] to the variable set1.

      var data = {
              "variable": "set1",
              "value": ["sval1", "sval2", "sval3"]
              };
      
      redis.add(data);
  • Hash datatype

    • Get the value of the variable hash1.

      redis.get({"variable": "hash1"}, function(err, res){
          if(err){
              console.log("ERROR: ", err.message);
          } else {
              console.log("Result: ", res.results);
          }
      });
  • List datatype
    • Get values of the (repeating & unsorted) array from the variable list1 with the position range from 1 to 3.

      redis.get({"variable": "list1", "index": [1, 3]}, function(err, res){
          if(err){
              console.log("ERROR: ", err.message);
          } else {
              console.log("Result: ", res.results);
          }
      });
  • Create the database mydb

    redis.sql({"variable": "mydb"}, function(err, res){
        if(err){
            console.log("ERROR: ", err.message);
        } else {
            console.log("Result: ", res.results);
        }
    });
  • Create the foo table for mydb database.

    let szSQL = "CREATE TABLE foo (A INT, B TEXT);";
    
     redis.sql({"variable": "mydb", "value": szSQL}, function(err, res){
        if(err){
            console.log("ERROR: ", err.message);
        } else {
            console.log("Result: ", res.results);
        }
    });
  • Note: It's not support for RedisEasy-client.

  • Set datatype

    • Delete the entire set1 variable

      redis.del({"variable": "set1"});
  • Hash datatype

    • Delete the values with hash keys "hkey1" and "hkey2" from hash object hash1.

      var data = {
              "variable": "hash1",
              "index": ["hkey1", "hkey2"]
              };
      
      redis.del(data);
  • Get the number of elements of the list1

    redis.count({"variable": "list1"}, function(err, res){
        if(err){
            console.log("ERROR: ", err.message);
        } else {
            console.log("Result: ", res.results);
        }
    });
  • Clear the variable list1

    redis.clear({"variable": "list1"});
  • Note: It's not support for RedisEasy-client.

  • Set the expiration time for the list1 in 10 seconds.

    redis.expire({"variable": "list1", "other":["EX", 10]});