Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis: How to access keys in specific keyspace

Tags:

redis

I have 2 keyspaces in my redis server:

db0:keys=1,expires=0
db1:keys=36679593,expires=0

But if I run

redis-cli KEYS '*'

I only get keys in db0. How can i search the keys in db1?

like image 450
Christoffer Avatar asked May 17 '13 16:05

Christoffer


2 Answers

You can use redis-cli with the -n option;

$ redis-cli -n 1 KEYS '*'

$ redis-cli --help
redis-cli 2.6.7

Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]
  ...
  -n <db>          Database number
  ...
like image 189
Joachim Isaksson Avatar answered Sep 25 '22 02:09

Joachim Isaksson


first, you need to select the db1. To do that use select 1. Then you can get all keys using KEYS *

select 1 // selects db 1

keys * // search all keys in selected db (db -1 )
like image 28
ifelse.codes Avatar answered Sep 26 '22 02:09

ifelse.codes