Reputation: 869
I am using Spring RedisTemplate to connect to Redis. I am using zadd to add data then calling zrange to check data value. It returns data just fine but when I call Key * i am not getting any results. Really Confused!! Please Help!! But when I run jedis it is working fine I see entries from cli etc.
System.out.println("********** ZRANGE IS " + redisTemplate.zrange(patternEmailsSetKey, 0l, -1l));
final Set<String> keys = redisTemplate.hkeys("*");
System.out.println("&&&&&&&&&&&&&&& KEY SIZE IS " + keys.size());
for(String key: keys) {
System.out.println("key: "+ key);
}
Returned
********** ZRANGE IS [{"subject":"ab ","eest":"aa","urls":["aa","ss"],"dd":0,"Id":11,"bId":999}] &&&&&&&&&&&&&&& KEY SIZE IS 0
Upvotes: 0
Views: 759
Reputation: 22906
ZRANGE
and ZADD
are commands for Sorted Set
, while HKEYS
is command for HASH
. So you are adding elements to a Sorted Set
, while trying to get fields of a HASH
.
If you want to get all members of the Sorted Set
, you need to use the ZSCAN
command.
Upvotes: 1