PgCache vs Amazon ElastiCache
Amazon ElastiCache is AWS's managed cache service. It runs Valkey, Redis OSS or Memcached. To cache RDS or Aurora reads in ElastiCache, your app writes query results into the cache and clears them when the data changes. PgCache sits in front of RDS or Aurora PostgreSQL, picks what to cache on its own, and keeps the cached data current through replication.
See which of your own queries PgCache would serve: check your workload or open a sample report.
ElastiCache facts checked against AWS's docs on .
PgCache
A caching proxy that runs in your VPC in front of RDS or Aurora PostgreSQL. It stores the data for your repeated reads in a separate, vanilla Postgres instance and keeps that data current through logical replication.
- No cache code or TTLs in the app
- Writes from any app, job or tool reach the cache
- Each connection reads its own writes
ElastiCache
AWS’s managed cache service, running Valkey, Redis OSS or Memcached. Your app reads and writes the cache by key.
Where they differ
| Topic | PgCache | ElastiCache |
|---|---|---|
| App changes | Point the connection string at PgCache | Cache code around your queries |
| Freshness | Within typical logical replication lag | Stale until your code clears the key or its TTL expires |
| Writes from other services and tools | Reach the cache through replication | Missed unless each one also clears the cache |
| What you run | PgCache on EC2 or in a container | A managed cache cluster, plus cache code in your app |
Which one fits
Choose PgCache when
- You run RDS or Aurora PostgreSQL 16 or later
- You don’t want cache code or TTLs in the app
Choose ElastiCache when
- You cache sessions, API responses or other data that isn’t a query result
- Your database is MySQL, or Postgres older than 16
What they have in common
- Both take repeated reads off RDS or Aurora
- Both run inside your VPC
Using them together
- ElastiCache for sessions and other data that doesn’t live in Postgres
- PgCache for the SQL reads you’d otherwise cache by hand
Common questions
Does PgCache use ElastiCache?
No. PgCache stores cached data in its own Postgres instance, so there’s no separate cache cluster to run.
What about AWS's JDBC query cache plugin?
AWS’s JDBC wrapper has a plugin that caches query results in ElastiCache for Java apps. You add a TTL hint to each query you want cached. PgCache needs no hints, works with any language, and keeps cached results current through replication.
Can I run PgCache on AWS?
Yes, on EC2 from the AWS Marketplace AMI or as a container, in the same VPC as your database.
Sources
- Amazon ElastiCache docs: Caching database query results
- AWS Advanced JDBC Wrapper: Remote Query Cache plugin
- PgCache docs: AWS Marketplace
If something here is out of date, please write to [email protected].
See where your own queries land
Step 1
Check your workload
Paste a pg_stat_statements export or a Postgres log. In about a minute you see which of your queries PgCache would serve from cache.
No export handy? See a sample report
Runs in your browser. Nothing is uploaded.
Step 2
Get a free workload review
30 minutes with the founders, by video or email. Bring your Fit report or your Postgres problem.
- What PgCache would serve and save on your workload
- If it fits, a pilot with hands-on help
Prefer email? [email protected]
Already curious? Request a pilot
Free. Pick any open time on our calendar.
Run it yourself: Source on GitHub · Try it in one command
Not ready yet? Get updates by email.