theja_swarup
theja_swarup

Reputation: 167

Get maximum value of number of keys (hlen) for hashes that match given pattern in Redis

I have many records that start with the pattern as shown below:

user:8d6120be2e7247e49545502092c389fd and

user:000935dc3bb16bd2e0de50988751acfd

Though the hash represent user object, one hash may have more keys than the other. Say if user is a Manager then he may have few additional keys like Reportees, Benifits etc., Without actually looking into all the records is there a way to know the maximum number of keys in any hash? I am in the process of converting the Redis structure in to Relational schema and this gives me an idea on what all columns should be present.

Upvotes: 0

Views: 666

Answers (1)

Nick Bondarenko
Nick Bondarenko

Reputation: 6351

Just use HLEN if your user:<hash> key is HSET. The most of data structures in redis have the way to get they len:

Upvotes: 1

Related Questions