Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis hgetall or hget?

Tags:

redis

There is redis hash with 100-200 fields. If I need take 2 or 3 values, what method is best way?

First way is call hgetall, but i got many useless data.

Second way is call hget key1, hget key2 and hgetkey3 - but is three different call.

like image 494
Михаил Поправко Avatar asked Dec 05 '22 13:12

Михаил Поправко


1 Answers

Do not use HGETALL unless you need the entire Hash's contents (beware, however, of its O(N) time complexity).

You can use the HMGET command to retrieve only those fields in the Hash that are of interest to you.

like image 108
Itamar Haber Avatar answered Feb 25 '23 10:02

Itamar Haber