I’m pretty new to redis and Nosql databases in general. I have a few questions in my mind. I’m writing some codes to test out redis with the library Rediska and I want to see how redis stores the values in the database.
I’m really confused my question is:
If I store some values in the database, how can I access them through the redis cli? Is there any command that can list all the lists?
For example, I’m testing the retwitter app that comes with the rediska library:
$userData = $form->getValues();
$userData['id'] = User::fetchNextId();
// save user
$user = new User($userData['id']);
$user->setValue($userData);
$users = new Users();
$users->add($userData['id']);
After the last instruction, the userid is saved to the db. I want to query redis with its client to see it.
How can i do that ?
You can always check all keys stored in the database, using the KEYS command (in this case,
keys *).After you find a key to inspect, using TYPE will retrieve the type of the key. Beware of case (i.e.
Useranduserare different keys).Based on the type, you now can filter the full command list to find the ones to issue against that type.
Now browsing the Rediska example,
Usersis a subclass ofRediska_Key_Set, so in Redis the structure is aSET. You can query sets using these commands.(for instance,
SMEMBERS [keyName]will list all members of the set).Finally, you can always call the
MONITORcommand inredis-cli, and then access the application. Every command issued against Redis will then be dumped on the screen.