Skip to content

pg_local_cache

Transaction-aware shared-memory cache serving PostgreSQL primary-key rows over RESP2 MGET

pg_local_cache : Transaction-aware shared-memory cache serving PostgreSQL primary-key rows over RESP2 MGET

Overview

ID Extension Package Version Category License Language
2890 pg_local_cache pg_local_cache 3.1.0 FEAT MIT C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd-- No Yes Yes Yes no no
Relationships
Schemas local_cache
Preload.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 3.1.0 19 18 17 16 15 pg_local_cache -
RPM PIGSTY 3.1.0 19 18 17 16 15 pg_local_cache_$v openssl-libs
DEB PIGSTY 3.1.0 19 18 17 16 15 postgresql-$v-pg-local-cache `libssl3
Linux / PG PG19 PG18 PG17 PG16 PG15
el8.x86_64 N/A PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
el8.aarch64 N/A PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
el9.x86_64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
el9.aarch64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
el10.x86_64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
el10.aarch64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
d12.x86_64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
d12.aarch64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
d13.x86_64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
d13.aarch64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
u22.x86_64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
u22.aarch64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
u24.x86_64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
u24.aarch64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
u26.x86_64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
u26.aarch64 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0 PIGSTY 3.1.0
Package Version OS ORG SIZE File URL
pg_local_cache_19 3.1.0 el9.x86_64 pigsty 257.8 KiB pg_local_cache_19-3.1.0-1PGSTY.el9.x86_64.rpm
pg_local_cache_19 3.1.0 el9.aarch64 pigsty 255.1 KiB pg_local_cache_19-3.1.0-1PGSTY.el9.aarch64.rpm
pg_local_cache_19 3.1.0 el10.x86_64 pigsty 260.5 KiB pg_local_cache_19-3.1.0-1PGSTY.el10.x86_64.rpm
pg_local_cache_19 3.1.0 el10.aarch64 pigsty 257.5 KiB pg_local_cache_19-3.1.0-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-local-cache 3.1.0 d12.x86_64 pigsty 242.4 KiB postgresql-19-pg-local-cache_3.1.0-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-local-cache 3.1.0 d12.aarch64 pigsty 236.9 KiB postgresql-19-pg-local-cache_3.1.0-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-local-cache 3.1.0 d13.x86_64 pigsty 242.4 KiB postgresql-19-pg-local-cache_3.1.0-1PGSTY~trixie_amd64.deb
postgresql-19-pg-local-cache 3.1.0 d13.aarch64 pigsty 237.0 KiB postgresql-19-pg-local-cache_3.1.0-1PGSTY~trixie_arm64.deb
postgresql-19-pg-local-cache 3.1.0 u22.x86_64 pigsty 264.4 KiB postgresql-19-pg-local-cache_3.1.0-1PGSTY~jammy_amd64.deb
postgresql-19-pg-local-cache 3.1.0 u22.aarch64 pigsty 262.1 KiB postgresql-19-pg-local-cache_3.1.0-1PGSTY~jammy_arm64.deb
postgresql-19-pg-local-cache 3.1.0 u24.x86_64 pigsty 250.6 KiB postgresql-19-pg-local-cache_3.1.0-1PGSTY~noble_amd64.deb
postgresql-19-pg-local-cache 3.1.0 u24.aarch64 pigsty 249.3 KiB postgresql-19-pg-local-cache_3.1.0-1PGSTY~noble_arm64.deb
postgresql-19-pg-local-cache 3.1.0 u26.x86_64 pigsty 247.2 KiB postgresql-19-pg-local-cache_3.1.0-1PGSTY~resolute_amd64.deb
postgresql-19-pg-local-cache 3.1.0 u26.aarch64 pigsty 245.3 KiB postgresql-19-pg-local-cache_3.1.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_local_cache_18 3.1.0 el8.x86_64 pigsty 255.6 KiB pg_local_cache_18-3.1.0-1PGSTY.el8.x86_64.rpm
pg_local_cache_18 3.1.0 el8.aarch64 pigsty 250.3 KiB pg_local_cache_18-3.1.0-1PGSTY.el8.aarch64.rpm
pg_local_cache_18 3.1.0 el9.x86_64 pigsty 258.9 KiB pg_local_cache_18-3.1.0-1PGSTY.el9.x86_64.rpm
pg_local_cache_18 3.1.0 el9.aarch64 pigsty 256.4 KiB pg_local_cache_18-3.1.0-1PGSTY.el9.aarch64.rpm
pg_local_cache_18 3.1.0 el10.x86_64 pigsty 260.3 KiB pg_local_cache_18-3.1.0-1PGSTY.el10.x86_64.rpm
pg_local_cache_18 3.1.0 el10.aarch64 pigsty 257.3 KiB pg_local_cache_18-3.1.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-local-cache 3.1.0 d12.x86_64 pigsty 242.2 KiB postgresql-18-pg-local-cache_3.1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-local-cache 3.1.0 d12.aarch64 pigsty 236.9 KiB postgresql-18-pg-local-cache_3.1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-local-cache 3.1.0 d13.x86_64 pigsty 242.3 KiB postgresql-18-pg-local-cache_3.1.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-local-cache 3.1.0 d13.aarch64 pigsty 237.1 KiB postgresql-18-pg-local-cache_3.1.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-local-cache 3.1.0 u22.x86_64 pigsty 264.3 KiB postgresql-18-pg-local-cache_3.1.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-local-cache 3.1.0 u22.aarch64 pigsty 261.9 KiB postgresql-18-pg-local-cache_3.1.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-local-cache 3.1.0 u24.x86_64 pigsty 250.4 KiB postgresql-18-pg-local-cache_3.1.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-local-cache 3.1.0 u24.aarch64 pigsty 249.2 KiB postgresql-18-pg-local-cache_3.1.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-local-cache 3.1.0 u26.x86_64 pigsty 247.1 KiB postgresql-18-pg-local-cache_3.1.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-local-cache 3.1.0 u26.aarch64 pigsty 245.1 KiB postgresql-18-pg-local-cache_3.1.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_local_cache_17 3.1.0 el8.x86_64 pigsty 255.5 KiB pg_local_cache_17-3.1.0-1PGSTY.el8.x86_64.rpm
pg_local_cache_17 3.1.0 el8.aarch64 pigsty 250.1 KiB pg_local_cache_17-3.1.0-1PGSTY.el8.aarch64.rpm
pg_local_cache_17 3.1.0 el9.x86_64 pigsty 258.5 KiB pg_local_cache_17-3.1.0-1PGSTY.el9.x86_64.rpm
pg_local_cache_17 3.1.0 el9.aarch64 pigsty 256.3 KiB pg_local_cache_17-3.1.0-1PGSTY.el9.aarch64.rpm
pg_local_cache_17 3.1.0 el10.x86_64 pigsty 259.9 KiB pg_local_cache_17-3.1.0-1PGSTY.el10.x86_64.rpm
pg_local_cache_17 3.1.0 el10.aarch64 pigsty 257.1 KiB pg_local_cache_17-3.1.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-local-cache 3.1.0 d12.x86_64 pigsty 242.2 KiB postgresql-17-pg-local-cache_3.1.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-local-cache 3.1.0 d12.aarch64 pigsty 236.7 KiB postgresql-17-pg-local-cache_3.1.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-local-cache 3.1.0 d13.x86_64 pigsty 242.4 KiB postgresql-17-pg-local-cache_3.1.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-local-cache 3.1.0 d13.aarch64 pigsty 236.5 KiB postgresql-17-pg-local-cache_3.1.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-local-cache 3.1.0 u22.x86_64 pigsty 283.7 KiB postgresql-17-pg-local-cache_3.1.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-local-cache 3.1.0 u22.aarch64 pigsty 281.2 KiB postgresql-17-pg-local-cache_3.1.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-local-cache 3.1.0 u24.x86_64 pigsty 250.2 KiB postgresql-17-pg-local-cache_3.1.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-local-cache 3.1.0 u24.aarch64 pigsty 249.0 KiB postgresql-17-pg-local-cache_3.1.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-local-cache 3.1.0 u26.x86_64 pigsty 246.9 KiB postgresql-17-pg-local-cache_3.1.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-local-cache 3.1.0 u26.aarch64 pigsty 244.8 KiB postgresql-17-pg-local-cache_3.1.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_local_cache_16 3.1.0 el8.x86_64 pigsty 255.5 KiB pg_local_cache_16-3.1.0-1PGSTY.el8.x86_64.rpm
pg_local_cache_16 3.1.0 el8.aarch64 pigsty 250.1 KiB pg_local_cache_16-3.1.0-1PGSTY.el8.aarch64.rpm
pg_local_cache_16 3.1.0 el9.x86_64 pigsty 258.5 KiB pg_local_cache_16-3.1.0-1PGSTY.el9.x86_64.rpm
pg_local_cache_16 3.1.0 el9.aarch64 pigsty 256.2 KiB pg_local_cache_16-3.1.0-1PGSTY.el9.aarch64.rpm
pg_local_cache_16 3.1.0 el10.x86_64 pigsty 259.9 KiB pg_local_cache_16-3.1.0-1PGSTY.el10.x86_64.rpm
pg_local_cache_16 3.1.0 el10.aarch64 pigsty 257.1 KiB pg_local_cache_16-3.1.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-local-cache 3.1.0 d12.x86_64 pigsty 242.1 KiB postgresql-16-pg-local-cache_3.1.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-local-cache 3.1.0 d12.aarch64 pigsty 236.5 KiB postgresql-16-pg-local-cache_3.1.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-local-cache 3.1.0 d13.x86_64 pigsty 242.2 KiB postgresql-16-pg-local-cache_3.1.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-local-cache 3.1.0 d13.aarch64 pigsty 236.7 KiB postgresql-16-pg-local-cache_3.1.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-local-cache 3.1.0 u22.x86_64 pigsty 282.3 KiB postgresql-16-pg-local-cache_3.1.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-local-cache 3.1.0 u22.aarch64 pigsty 280.0 KiB postgresql-16-pg-local-cache_3.1.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-local-cache 3.1.0 u24.x86_64 pigsty 250.2 KiB postgresql-16-pg-local-cache_3.1.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-local-cache 3.1.0 u24.aarch64 pigsty 251.7 KiB postgresql-16-pg-local-cache_3.1.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-local-cache 3.1.0 u26.x86_64 pigsty 246.9 KiB postgresql-16-pg-local-cache_3.1.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-local-cache 3.1.0 u26.aarch64 pigsty 244.7 KiB postgresql-16-pg-local-cache_3.1.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_local_cache_15 3.1.0 el8.x86_64 pigsty 256.9 KiB pg_local_cache_15-3.1.0-1PGSTY.el8.x86_64.rpm
pg_local_cache_15 3.1.0 el8.aarch64 pigsty 251.3 KiB pg_local_cache_15-3.1.0-1PGSTY.el8.aarch64.rpm
pg_local_cache_15 3.1.0 el9.x86_64 pigsty 260.8 KiB pg_local_cache_15-3.1.0-1PGSTY.el9.x86_64.rpm
pg_local_cache_15 3.1.0 el9.aarch64 pigsty 258.0 KiB pg_local_cache_15-3.1.0-1PGSTY.el9.aarch64.rpm
pg_local_cache_15 3.1.0 el10.x86_64 pigsty 261.9 KiB pg_local_cache_15-3.1.0-1PGSTY.el10.x86_64.rpm
pg_local_cache_15 3.1.0 el10.aarch64 pigsty 258.4 KiB pg_local_cache_15-3.1.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-local-cache 3.1.0 d12.x86_64 pigsty 243.9 KiB postgresql-15-pg-local-cache_3.1.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-local-cache 3.1.0 d12.aarch64 pigsty 263.0 KiB postgresql-15-pg-local-cache_3.1.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-local-cache 3.1.0 d13.x86_64 pigsty 243.9 KiB postgresql-15-pg-local-cache_3.1.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-local-cache 3.1.0 d13.aarch64 pigsty 237.9 KiB postgresql-15-pg-local-cache_3.1.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-local-cache 3.1.0 u22.x86_64 pigsty 284.7 KiB postgresql-15-pg-local-cache_3.1.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-local-cache 3.1.0 u22.aarch64 pigsty 282.6 KiB postgresql-15-pg-local-cache_3.1.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-local-cache 3.1.0 u24.x86_64 pigsty 252.4 KiB postgresql-15-pg-local-cache_3.1.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-local-cache 3.1.0 u24.aarch64 pigsty 251.0 KiB postgresql-15-pg-local-cache_3.1.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-local-cache 3.1.0 u26.x86_64 pigsty 249.4 KiB postgresql-15-pg-local-cache_3.1.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-local-cache 3.1.0 u26.aarch64 pigsty 247.4 KiB postgresql-15-pg-local-cache_3.1.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_local_cache;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_local_cache;		# install via package name, for the active PG version

pig install pg_local_cache -v 19;   # install for PG 19
pig install pg_local_cache -v 18;   # install for PG 18
pig install pg_local_cache -v 17;   # install for PG 17
pig install pg_local_cache -v 16;   # install for PG 16
pig install pg_local_cache -v 15;   # install for PG 15

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_local_cache';

Create this extension with:

CREATE EXTENSION pg_local_cache;

Usage

Sources:

pg_local_cache 3.1.0 caches whole rows by their complete primary key in bounded shared memory. Cached reads now use authenticated RESP MGET; SQL local_cache.mget is removed and ordinary SELECT queries are not rewritten. PostgreSQL remains the durable source of truth.

Core Workflow

shared_preload_libraries = 'pg_local_cache'
pg_local_cache.database = 'app'
pg_local_cache.role = 'local_cache_worker'
pg_local_cache.bind_address = '127.0.0.1'
pg_local_cache.port = 6380
pg_local_cache.auth_token_file = '/secure/path/token'
CREATE EXTENSION pg_local_cache;
CREATE TABLE public.items (id bigint PRIMARY KEY, value text);
INSERT INTO public.items VALUES (42, 'example');
SELECT local_cache.attach_table('public.items'::regclass);
SELECT local_cache.health();

After authenticating the RESP connection:

MGET CRUD:app.public.items:{"id":42} CRUD:app.public.items:{"id":7}

Operational Boundaries

Append the library to existing preload entries, provision a dedicated worker role and its documented metadata/table grants, secure the token file, and restart. A superuser creates the extension in fixed schema local_cache. Attach only supported permanent primary-key tables. RESP MGET preserves order and duplicate keys and returns null for missing rows. Workers use the configured database role, not the client’s SQL privileges, transaction or snapshot. Keep joins, projections, row locks and session-sensitive reads in ordinary SQL.

local_cache.attach_table installs invalidation triggers; local_cache.detach_table removes a mapping; local_cache.reconcile_table revalidates it after DDL or privilege changes. local_cache.health, local_cache.stats and local_cache.metrics report readiness and resource use. Normal PostgreSQL writes invalidate affected cache entries. RLS, partitioned and inherited tables are outside the documented workload. There is no TTL or distributed cache coordination.

Supports PostgreSQL 14–18 on one writable primary. Non-loopback listeners require pg_local_cache.tls or explicit pg_local_cache.allow_plaintext_network opt-in. TLS uses separate certificate/key settings; a CA setting enables mutual TLS. The reloadable pg_local_cache.enabled switch disables caching.

Before upgrading from 2.x, move SQL MGET callers to the RESP authorization model. Install matching 3.1.0 files, configure listener security, restart, confirm the library version and listener readiness, then run ALTER EXTENSION pg_local_cache UPDATE in each affected database. Dependencies on removed functions or the replaced metrics return type can block migration; the script deliberately avoids CASCADE. No downgrade script is supplied.

Upgrade from 3.0.0 to 3.1.0

Version 3.1.0 changes the shared-memory layout and fixes stale-read races and worker memory leaks. Restart PostgreSQL after installing the matching library, then update the extension in each database; the SQL migration itself changes no objects or attached-table mappings. Verify pg_local_cache.binary_version and local_cache.health() afterward.

pg_local_cache.cache_entries now counts descriptors, while byte capacity comes from slab storage. Review pg_local_cache.lock_partitions, dirty-marker limits, the new pg_local_cache.max_deferred_misses, client slots and the process file-descriptor limit before restarting. MGET deduplicates misses, but single-flight waiters can use later transactions; a complete response is not guaranteed to share one snapshot.

Table reader