# ReadySet — Wire-Compatible SQL Caching for Postgres and MySQL > A lightweight SQL cache that sits between your application and database, automatically keeping query results fresh using the replication stream. ## Install Save as a script file and run: # ReadySet — Wire-Compatible SQL Caching for Postgres and MySQL ## Quick Use ```bash # Run ReadySet as a Docker container proxying a PostgreSQL database docker run -d --name readyset -e UPSTREAM_DB_URL=postgresql://user:pass@db-host:5432/mydb -e LISTEN_ADDRESS=0.0.0.0:5433 -p 5433:5433 readysettech/readyset:latest # Point your app at localhost:5433 instead of the upstream database ``` ## Introduction ReadySet is a SQL caching engine that drops in between your application and your PostgreSQL or MySQL database. It speaks the native wire protocol, so no code changes are required. Queries you choose to cache are served from an in-memory dataflow graph that stays up to date automatically by tailing the database replication stream. ## What ReadySet Does - Proxies the Postgres or MySQL wire protocol so applications connect without driver changes - Caches selected query results in memory and updates them incrementally from the binlog or WAL - Reduces read latency and database load without application-level cache invalidation logic - Provides a SQL command interface to inspect and manage which queries are cached - Falls through to the upstream database for uncached or unsupported queries transparently ## Architecture Overview ReadySet uses a streaming dataflow engine inspired by the Noria research project. When a query is marked for caching, ReadySet compiles it into a dataflow graph of operators. The replication stream from the upstream database feeds change events into this graph, and the operators incrementally maintain materialized views in memory. Reads hit the materialized state directly, avoiding a round-trip to the origin database. ## Self-Hosting & Configuration - Deploy as a single binary or Docker container between your app and database - Set UPSTREAM_DB_URL to point at the existing Postgres or MySQL instance - Run SHOW PROXIED QUERIES to see which queries are flowing through - Cache a query with CREATE CACHE FROM followed by the query fingerprint - Monitor memory usage and cache hit rates through built-in metrics endpoints ## Key Features - Zero application code changes — compatible with existing Postgres and MySQL drivers - Automatic incremental cache maintenance via replication, no TTL or manual invalidation - Sub-millisecond reads for cached queries, even under high write throughput - Query-level control over what gets cached and what passes through - Snapshot and streaming replication support for initial state and ongoing changes ## Comparison with Similar Tools - **Redis / Memcached** — general key-value caches; ReadySet caches SQL results with automatic invalidation - **Materialize** — full streaming SQL database; ReadySet is a transparent proxy layer - **ProxySQL** — MySQL query routing and caching; ReadySet maintains incrementally updated views - **PgBouncer** — connection pooling only; ReadySet adds a caching data plane - **Amazon ElastiCache** — managed Redis/Memcached; ReadySet eliminates manual cache logic ## FAQ **Q: Do I need to change my application code to use ReadySet?** A: No. ReadySet speaks the Postgres or MySQL wire protocol. Point your connection string at ReadySet instead of the origin database and it works transparently. **Q: How does ReadySet keep cached data fresh?** A: It tails the database replication stream (WAL for Postgres, binlog for MySQL) and incrementally updates its in-memory views as writes happen upstream. **Q: What happens if ReadySet goes down?** A: Queries fall through to the upstream database. When ReadySet restarts, it re-snapshots the relevant tables and resumes streaming replication. **Q: Which SQL queries can ReadySet cache?** A: Most SELECT queries with joins, filters, and aggregations are supported. Complex features like recursive CTEs or window functions may fall through to the upstream database. ## Sources - https://github.com/readysettech/readyset - https://readyset.io/ --- Source: https://tokrepo.com/en/workflows/asset-59bd7fe6 Author: Script Depot