views:

83

answers:

2

I'm using an ORM called Ohm in Ruby that works on top of Redis and am curious to find out how the data is actually stored. I was wondering if there is way to list all the keys/values in a Redis db.

Any lead will go a long way in helping me out (I'm basically stuck atm). Thanks in advance!

Update:
A note for others trying this out using redis-cli, use this:

$ redis-cli keys
* (press * followed by Ctrl-D)
... (prints a list of keys and exits)
$

Thanks @antirez and @hellvinz!

+3  A: 

Hello,

you can explore the Redis dataset using the 'redis-cli' tool included in the Redis distribution.

Just start the tool without arguments, then type commands to explore the dataset.

For instance KEYS will list all the keys matching a glob-style pattern, for instance with: keys * you'll see all the keys available.

Then you can use the TYPE command to check what type is a given key, if it's a list you can retrieve the elements inside using LRANGE mykey 0 -1, if It is a Set you'll use instead SMEMBERS mykey and so forth. Check the Redis documentation for a list of all the available commands and how they works.

Cheers, Salvatore

antirez
Thanks. I found that really helpful!
Jagtesh Chadha
+1  A: 

Just add a practical ruby example to the antirez response (i won't dare competing with him)

irb(main):002:0> require 'rubygems'
=> true
irb(main):003:0> require 'redis'
=> true
irb(main):004:0> r = Redis.new
=> #<Redis:0x8605b64 @sock=#<TCPSocket:0x8605ab0>, @timeout=5, @port=6379, @db=0, @host="127.0.0.1">
irb(main):005:0> r.keys('*')
hellvinz
Thanks! It's crystal clear to me now :)
Jagtesh Chadha