0
0
Redisquery~5 mins

HGETALL for all fields in Redis

Choose your learning style9 modes available
Introduction
HGETALL helps you get all the information stored in a group of key-value pairs inside Redis, so you can see everything at once.
When you want to see all details about a user stored in Redis.
When you need to get all settings saved in a Redis hash for an application.
When you want to check all fields and values of a product stored in Redis.
When debugging to see what data is inside a Redis hash key.
Syntax
Redis
HGETALL key
The command returns all fields and their values stored in the hash at the given key.
If the key does not exist, it returns an empty list.
Examples
Gets all fields and values for the user with ID 1000.
Redis
HGETALL user:1000
Retrieves all configuration settings stored in the 'settings' hash.
Redis
HGETALL settings
Sample Program
First, we store three fields for user:1. Then we get all fields and values for user:1.
Redis
HMSET user:1 name "Alice" age "30" city "Paris"
HGETALL user:1
OutputSuccess
Important Notes
The output is a list where fields and values alternate.
Use HGETALL only when you want all data; for specific fields, use HGET.
In newer Redis versions, consider using HGETALL carefully with large hashes to avoid performance issues.
Summary
HGETALL returns all fields and values from a Redis hash key.
It is useful to see complete data stored in a hash at once.
The output lists fields and values in order.