Skip to content

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

TypeBacking tablePrimary useRepresentative commands
Stringredis._stringByte sequences, integers, floats, or bitmapsSET, GET, MSET, MGET, INCR, INCRBYFLOAT, LCS
Hashredis._hashField/value maps under one keyHSET, HGET, HMGET, HGETALL, HINCRBY, HRANDFIELD, HSCAN
Listredis._list, redis._list_lengthOrdered sequences of elements (duplicates allowed)LPUSH, RPUSH, LPOP, LRANGE, LINDEX, LINSERT, BLMOVE, BLPOP
Setredis._setUnordered collections of unique membersSADD, SREM, SMEMBERS, SISMEMBER, SUNION, SINTER, SSCAN
Sorted setredis._zsetUnique members ordered by float8 score, then raw member bytesZADD, ZRANGE, ZREM, ZSCORE, ZRANK, ZUNIONSTORE, BZPOPMIN
Streamredis._stream, redis._stream_group, redis._stream_pelAppend-only entries ordered by (ms, seq) ID with consumer groupsXADD, 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, 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

  • 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.
  • 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).
Scan to open this page
https://mimus.pgsty.com/docs/redis/reference/data-types/

Table reader