pg_local_cache
pg_local_cache : Transaction-aware shared-memory cache for ordinary PostgreSQL primary-key reads
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2890 | pg_local_cache | pg_local_cache | 2.0.4 |
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 |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 2.0.4 |
18 17 16 15 14 | pg_local_cache |
- |
| RPM | PIGSTY | 2.0.4 |
18 17 16 15 14 | pg_local_cache_$v |
- |
| DEB | PIGSTY | 2.0.4 |
18 17 16 15 14 | postgresql-$v-pg-local-cache |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| el8.aarch64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| el9.x86_64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| el9.aarch64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| el10.x86_64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| el10.aarch64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| d12.x86_64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| d12.aarch64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| d13.x86_64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| d13.aarch64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| u22.x86_64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| u22.aarch64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| u24.x86_64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| u24.aarch64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| u26.x86_64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
| u26.aarch64 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 | PIGSTY 2.0.4 |
Source
github.com/profundium/pg_local_cache
pg_local_cache-2.0.4.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
Usage
Sources:
- README.md
- pg_local_cache.control
- sql/pg_local_cache–3.0.0.sql
- sql/pg_local_cache–2.0.4–3.0.0.sql
- docs/UPGRADING.md
- CHANGELOG.md
pg_local_cache 3.0.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
After authenticating the RESP connection:
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.0.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.