Skip to main content
added 98 characters in body
Source Link
Andrew Lavers
  • 8.2k
  • 1
  • 37
  • 50

Also while inserting into the database, is inserting the object as a whole the best way to go about?

No, not for the sample query you propose. Redis is not a key value storetraditional database, it's more like a key value store, it doesn't understand your object's structure.

If you want to make queries like you suggest, you might be using the wrong tool.

In redis you wouldn't store an object, but you could store simpler structures, like a hash. Stealing from the node_redis examples:

client.hmset("hosts", "mjr", "1", "another", "23", "home", "1234");
client.hgetall("hosts", function (err, obj) {
    console.dir(obj);
});

Output:

{ mjr: '1', another: '23', home: '1234' }

For more details, check out the redis docs here: http://redis.io/commands

Also while inserting into the database, is inserting the object as a whole the best way to go about?

No, not for the sample query you propose. Redis is a key value store, it doesn't understand your object's structure.

If you want to make queries like you suggest, you might be using the wrong tool.

In redis you wouldn't store an object, but you could store simpler structures, like a hash. Stealing from the node_redis examples:

client.hmset("hosts", "mjr", "1", "another", "23", "home", "1234");
client.hgetall("hosts", function (err, obj) {
    console.dir(obj);
});

Output:

{ mjr: '1', another: '23', home: '1234' }

For more details, check out the redis docs here: http://redis.io/commands

Also while inserting into the database, is inserting the object as a whole the best way to go about?

No, not for the sample query you propose. Redis is not a traditional database, it's more like a key value store, it doesn't understand your object's structure.

If you want to make queries like you suggest, you might be using the wrong tool.

In redis you wouldn't store an object, but you could store simpler structures, like a hash. Stealing from the node_redis examples:

client.hmset("hosts", "mjr", "1", "another", "23", "home", "1234");
client.hgetall("hosts", function (err, obj) {
    console.dir(obj);
});

Output:

{ mjr: '1', another: '23', home: '1234' }

For more details, check out the redis docs here: http://redis.io/commands

Source Link
Andrew Lavers
  • 8.2k
  • 1
  • 37
  • 50

Also while inserting into the database, is inserting the object as a whole the best way to go about?

No, not for the sample query you propose. Redis is a key value store, it doesn't understand your object's structure.

If you want to make queries like you suggest, you might be using the wrong tool.

In redis you wouldn't store an object, but you could store simpler structures, like a hash. Stealing from the node_redis examples:

client.hmset("hosts", "mjr", "1", "another", "23", "home", "1234");
client.hgetall("hosts", function (err, obj) {
    console.dir(obj);
});

Output:

{ mjr: '1', another: '23', home: '1234' }

For more details, check out the redis docs here: http://redis.io/commands