# Data types

> Strings, hashes, lists, sets, sorted sets, streams, bitmaps, HyperLogLog and geo.

---

LLMS index: [llms.txt](/llms.txt)

---

`pgredis` implements command families for the core Redis 7.2.4 data types and derived structures inside PostgreSQL 18 tables. Every key has one metadata row in `redis._keyspace` and stores its payload in the matching typed table. See [Storage](/docs/redis/architecture/storage/) for the underlying table layout and [Commands](/docs/redis/reference/commands/) for the per-command list.

## Core types {#core}

{.wide}
| Type | Backing table | Primary use | Representative commands |
| --- | --- | --- | --- |
| String | `redis._string` | Byte sequences, integers, floats, or bitmaps | `SET`, `GET`, `MSET`, `MGET`, `INCR`, `INCRBYFLOAT`, `LCS` |
| Hash | `redis._hash` | Field/value maps under one key | `HSET`, `HGET`, `HMGET`, `HGETALL`, `HINCRBY`, `HRANDFIELD`, `HSCAN` |
| List | `redis._list`, `redis._list_length` | Ordered sequences of elements (duplicates allowed) | `LPUSH`, `RPUSH`, `LPOP`, `LRANGE`, `LINDEX`, `LINSERT`, `BLMOVE`, `BLPOP` |
| Set | `redis._set` | Unordered collections of unique members | `SADD`, `SREM`, `SMEMBERS`, `SISMEMBER`, `SUNION`, `SINTER`, `SSCAN` |
| Sorted set | `redis._zset` | Unique members ordered by `float8` score, then raw member bytes | `ZADD`, `ZRANGE`, `ZREM`, `ZSCORE`, `ZRANK`, `ZUNIONSTORE`, `BZPOPMIN` |
| Stream | `redis._stream`, `redis._stream_group`, `redis._stream_pel` | Append-only entries ordered by `(ms, seq)` ID with consumer groups | `XADD`, `XRANGE`, `XREAD`, `XGROUP`, `XREADGROUP`, `XACK`, `XAUTOCLAIM` |
{.wide .expand}

Keys, string values, hash fields, list elements, set members, and sorted-set members are stored as `bytea` and preserve arbitrary binary sequences, including `NUL` (`\x00`) bytes. When calling from SQL with non-UTF-8 or `NUL`-containing bytes, use [`redis.command_bin`](/docs/redis/tutorial/binary-data/).

## Bitmaps, GEO, and HyperLogLog {#derived}

- **Bitmaps:** `SETBIT`, `GETBIT`, `BITCOUNT`, `BITPOS`, `BITOP`, and `BITFIELD` / `BITFIELD_RO` operate on the underlying String value in `redis._string` (`redis._bitmap` helpers), preserving byte-exact compatibility with `GET` and `SET`.
- **GEO:** `GEOADD`, `GEODIST`, `GEOHASH`, `GEOPOS`, `GEORADIUS`, `GEORADIUSBYMEMBER`, `GEOSEARCH`, and `GEOSEARCHSTORE` store 52-bit geohash integers as scores inside `redis._zset`. Radius and box queries, result limits, `ASC`/`DESC` ordering, and destination key writes are supported; manually inserted scores outside the valid GEO domain differ from Redis in edge-case error reporting.
- **HyperLogLog:** `PFADD`, `PFCOUNT`, and `PFMERGE` store the Redis 7.2.4 sparse and dense HLL representations inside String values (`HYLL` header), so `GET` and `SET` can read or restore raw HyperLogLog state directly.

## Object operations {#objects}

- **`DUMP` and `RESTORE`:** `DUMP` serializes a single key in Redis RDB v11 payload format with a 64-bit CRC64 checksum, and `RESTORE` reconstructs the key (`REPLACE`, `ABSTTL`, `IDLETIME`, `FREQ`). They operate on individual keys and do not read or write whole-instance `.rdb` or AOF files; use PostgreSQL backup tools for [database backups](/docs/redis/operations/upgrade/#backup).
- **`OBJECT` and `DEBUG OBJECT`:** `OBJECT ENCODING` reports the Redis-compatible encoding name (`int`, `embstr`, `raw`, `listpack`, `hashtable`, `skiplist`, `stream`). `OBJECT IDLETIME` and `OBJECT FREQ` require `pg_redis.object_heat_tracking = on`, and exact listpack/quicklist transition tracking requires `pg_redis.list_layout_tracking = on` (both default to `off` so ordinary reads and list writes avoid extra metadata updates; see [Compatibility](/docs/redis/compatibility/#object-metadata)).

---

Backlinks:

- [Reference](/docs/redis/reference/)
