spat
spat · Redis-like In-Memory DB Embedded in Postgres
Overview
PostgreSQL · 17
Usage
Sources:
spat is an alpha, Redis-like key/value store embedded in PostgreSQL dynamic shared memory. It provides strings, sets, lists, hashes, TTLs, and named in-memory namespaces for caches or cross-session transient state; it is not a transactional or durable table replacement.
Core Workflow
spset accepts text and integer values directly, plus a generic anyelement path that stores PostgreSQL’s textual representation. It returns the spvalue output type; cast retrieved text again when reconstructing values such as JSONB.
Main Objects
spget,sptype, anddelread, inspect, and remove a key.sadd,sismember,scard,srem, andsinteroperate on sets.lpush,rpush,lpop,rpop, andllenoperate on lists.hsetandhgetoperate on hash fields.getexpireatandttlinspect expiration;sp_db_nitems,sp_db_size_bytes, andsp_db_sizeinspect the current namespace.spat.dbselects a named shared-memory namespace for the session.
ACID and Version Boundary
Changes take effect immediately, survive transaction rollback, and are visible to other sessions without MVCC isolation. They are not WAL-logged and all data disappears on PostgreSQL restart or crash. Per-key locks protect in-memory structures, but they do not add PostgreSQL transaction semantics.
The upstream README labels the project alpha, not production-ready, and requires PostgreSQL 17+ for the dynamic shared-memory registry. The catalog target is 0.1.0a4, while the reviewed upstream control and SQL now declare 0.1.0a5; verify the packaged a4 function signatures before using examples based on a5.