# Hashes — Redis Fundamentals: Caching, Data Structures and Persistence

Source: https://www.skillbyai.com/en/redis/redis-hashes

> Group related fields under one key with hashes and update single fields with HSET and HINCRBY.

## HSET & HGET

A **hash** groups related fields under one key instead of spreading them across many `SET` calls.

```bash
HSET user:1 name "Ada" age "36" city "London"
HGET user:1 name
HGETALL user:1
```

Output:

```
(integer) 3
"Ada"
1) "name"
2) "Ada"
3) "age"
4) "36"
5) "city"
6) "London"
```

## Updating one field

`HINCRBY` bumps a numeric field without touching the rest of the hash.

```bash
HINCRBY user:1 login_count 1
```

Output:

```
(integer) 1
```

## A record in a drawer

Think of a hash as one drawer (`user:1`) holding labeled slips of paper (fields) — you can pull out just `name` without opening the whole drawer.
