Data types
Strings, hashes, lists, sets, sorted sets, streams, bitmaps, HyperLogLog and geo.
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 for the underlying table layout and Commands for the per-command list.
Core types
| 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 |
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.
Bitmaps, GEO, and HyperLogLog
- Bitmaps:
SETBIT,GETBIT,BITCOUNT,BITPOS,BITOP, andBITFIELD/BITFIELD_ROoperate on the underlying String value inredis._string(redis._bitmaphelpers), preserving byte-exact compatibility withGETandSET. - GEO:
GEOADD,GEODIST,GEOHASH,GEOPOS,GEORADIUS,GEORADIUSBYMEMBER,GEOSEARCH, andGEOSEARCHSTOREstore 52-bit geohash integers as scores insideredis._zset. Radius and box queries, result limits,ASC/DESCordering, 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, andPFMERGEstore the Redis 7.2.4 sparse and dense HLL representations inside String values (HYLLheader), soGETandSETcan read or restore raw HyperLogLog state directly.
Object operations
DUMPandRESTORE:DUMPserializes a single key in Redis RDB v11 payload format with a 64-bit CRC64 checksum, andRESTOREreconstructs the key (REPLACE,ABSTTL,IDLETIME,FREQ). They operate on individual keys and do not read or write whole-instance.rdbor AOF files; use PostgreSQL backup tools for database backups.OBJECTandDEBUG OBJECT:OBJECT ENCODINGreports the Redis-compatible encoding name (int,embstr,raw,listpack,hashtable,skiplist,stream).OBJECT IDLETIMEandOBJECT FREQrequirepg_redis.object_heat_tracking = on, and exact listpack/quicklist transition tracking requirespg_redis.list_layout_tracking = on(both default tooffso ordinary reads and list writes avoid extra metadata updates; see Compatibility).
