[SOLVED] Redis: Usage in Meteor


Hi all,

I’m starting to test the Redis utilization in Meteor, I’m using a livedata library.

I created a database instance by :

Redis = new Meteor.RedisCollection("redis");

and add a test element by :

   "click .run":function(){
       alert('pre click');
       Redis.set("prova elemento");
       alert('post click');

Now I have to control if this database was created.

There is a command like :

meteor mongo   ?

now i try to check if database was created by ./redis-cli command, in the linux shell and later CONFIG GET database, but I can’t find ‘redis’ db.

It’s a code wrong or other?

Thanks a lot.



There will be no redis db. From the documentation:

You can instantiate a RedisCollection on both client and on the server. The collection can be either unnamed (unmanaged, just in-memory) or must be “redis” as Redis doesn’t have any concept of namespaced collections.

So, “redis” is just a required value to distinguish between a mini-redis collection and a real Redis collection:

R1 = new Meteor.RedisCollection(null); // mini-redis


R1 = new Meteor.RedisCollection('redis'); // real Redis

There is no meteor redis type command. If you have used a real Redis collection, you can just use the redis-cli command to interact with Redis from the command line.

Finally, your sample code:

   "click .run":function(){
       alert('pre click');
       Redis.set("prova elemento");
       alert('post click');

Your Redis.set statement is not correct for a Redis set operation: you need a key, value pair:

Redis.set('prova', 'elemento');

will add a key ‘prova’ with a value ‘elemento’ to Redis:

redis-cli get prova

[EDIT: To clarify choose one of managed or unmanaged collection. There is only one actual Redis database and only one collection. I suspect trying to naively add multiple collections and/or a mix of unmanaged and managed collections would result in endless fun :wink:]


Thanks a lot!

You are my savior:))