Redis is a fast in-memory data store, so using it as a query cache means the application owns the cache keys, serialization, TTLs, and invalidation. Readyset is a wire-compatible SQL caching proxy for PostgreSQL and MySQL: its pull-based cache stores query results behind the database connection, so the application keeps sending plain SQL. Readyset replaces Redis only as a SQL query result cache; Redis keeps everything else.
Redis is a data structure server. It keeps strings, hashes, JSON documents, sets, sorted sets, streams and other types in memory, and it serves reads from memory in under a millisecond.
Redis does many jobs besides caching: session storage with expiry, rate limiting, leaderboards built on sorted sets, job queues, pub/sub messaging and event streams.
Redis also has a broad ecosystem. Client libraries cover most major languages, and frameworks such as Spring and Django include Redis-backed caching. For data the database does not own, such as API responses, rendered fragments and computed values, Redis is the natural cache.
Caching SQL query results is a narrower job than the rest of what Redis does, and it is a job where Redis asks a lot of the application.
Using Redis as a SQL query cache is application-level caching. Redis documents the pattern as cache-aside: the application reads Redis first, falls back to the database on a miss, writes the result back to Redis, and on every update writes the database and then invalidates the cache key.
Most steps of cache-aside are application code and application policy. The application designs a key for each query and its parameters, serializes the result set into a Redis value and back, and chooses a TTL for each kind of data. The Redis server needs an eviction policy such as allkeys-lru for when it reaches its maxmemory limit.
Cache invalidation is the hardest part. On every write, the application must find every cached result the write affects, including joins and aggregates that read other tables, and delete or rewrite them. In our invalidation experiment, six read paths served the same story page on a MySQL database under identical writes: the database directly, two Redis look-aside caches, two Readyset pull-based caches and a Readyset push-based cache. A plausible set of per-table rules for Redis never converged to correct results after an author rename, because the cached pages that joined the renamed table were never invalidated.
Cache stampede is the second hardest part. When a popular key expires under high concurrency, many processes query the database for the same record at once. Redis documents Lua scripting for mutex locks or probabilistic early refresh as the defense, and the application carries that code.
Frameworks reduce the boilerplate, but the invalidation policy still lives in the application. A change data capture (CDC) pipeline such as Redis Data Integration or Debezium can keep Redis current from the database instead. It is a pipeline to build and run, it holds table records as hashes or JSON documents, and the whole working set must fit in memory.
Readyset is a wire-compatible SQL caching proxy for PostgreSQL and MySQL. The application connects to Readyset with its existing driver, Readyset answers the queries that have a cache, and Readyset proxies every other query to the database.
Readyset's pull-based cache is the counterpart to a Redis query cache. A pull-based cache stores a query's result set in Readyset's memory for a time-to-live (TTL) and refreshes it from the database in the background. CREATE SHALLOW CACHE creates a pull-based cache, for example CREATE SHALLOW CACHE WITH (POLICY TTL 60 SECONDS REFRESH 10 SECONDS) FROM followed by the query. Pull-based caches accept almost any read query and need no replication stream.
Readyset builds cache keys without application code. Readyset turns the literal values in a query into parameters, so queries that differ only in their values share one cache, with a separate entry for each parameter set.
Readyset also handles refresh and stampedes. With REFRESH, a read that finds an older entry gets the cached result immediately while Readyset refreshes it in the background. With COALESCE, concurrent requests for the same missing result share one query to the database. With ADAPTIVE, Readyset shortens the refresh interval of a result that keeps changing and lengthens it for one that does not.
Readyset sizes its pull-based store as a share of its memory limit. When the store is full, Readyset keeps the results that save the most database time, weighing how often each is requested against how long its query takes, and it serves result sets above a configured size from the database without caching them.
Readyset is a Redis cache alternative for SQL query results on MySQL and PostgreSQL, and not for sessions, queues or other data.
Redis is a general-purpose data store used here as a query cache, while Readyset is a SQL proxy built to cache query results.
| Redis as a query cache | Readyset pull-based cache |
|---|
| Application code | The application reads, writes and invalidates cache entries | The application sends SQL, and Readyset caches selected queries |
| SQL awareness and key design | The application builds a key for every query and parameter set and serializes results | Readyset parameterizes queries automatically and stores result sets |
| Cache invalidation | The application deletes or rewrites keys on every write | Readyset has no invalidation step: freshness comes from the TTL and refresh settings |
| Stampede protection | Application-side locks or early refresh | Readyset refreshes in the background and coalesces concurrent misses |
| Eviction and memory | The Redis server needs maxmemory and an eviction policy configured | Readyset uses a share of its memory limit with cost-aware admission |
| Infrastructure | A Redis service to deploy, size and monitor | A Readyset service in front of the database to deploy, size and monitor |
| Write handling | The application writes the database and updates the cache | Writes pass through Readyset to the database unchanged |
| What a cache hit and a miss cost | One round trip to Redis on a hit. On a miss, a Redis lookup, a database query, and a write back to Redis that the application issues | One round trip to Readyset on a hit. On a miss, still one round trip from the application, with Readyset querying the database |
Alternatives to a Redis query cache differ in who does the work of keeping results correct.
Another in-memory key-value cache used as a query cache follows the same cache-aside pattern, so the application still owns the keys, serialization and invalidation.
Read replicas add capacity by running every query against a copy of the database. They spread the work without removing it, and each replica is a full copy of the data to run and pay for.
Materialized views, in databases that support them, store a query result and refresh it on a schedule or on demand, so the result is only as current as the last refresh.
A SQL caching proxy moves the cache behind the database connection. Readyset's pull-based cache is a Redis cache alternative for SQL query results that serves them from memory for a TTL, and its push-based cache keeps results current by following the database's replication stream.
Redis can be fresher than a TTL cache when the application deletes a key at the moment it writes. Redis does not do this on its own: a key that no write path invalidates stays stale until its TTL expires or it is evicted. In our invalidation experiment, which timed how long after a MySQL write a reader first saw the new value, a correctly invalidated Redis look-aside cache was fresh to within about a millisecond, while a Readyset pull-based cache with a 10-second TTL and a 5-second refresh lagged by seconds. Each write to the Redis look-aside cache was also followed by a burst of identical queries to the database as readers refilled the key.
A Readyset pull-based cache has no invalidation step, so its results are as old as the refresh interval and TTL allow. An entry that is read continuously stays no more than about one refresh interval behind the database, and an entry nobody reads for a full TTL is dropped.
A Readyset push-based cache stays current by following the MySQL binlog or the PostgreSQL write-ahead log (WAL) and not by refreshing on an interval, and it is eventually consistent. A query that must reflect a write immediately is a candidate for a push-based cache, or it can stay uncached so that Readyset proxies it to the database.
Readyset also provides read-your-writes controls: a transaction policy on each cache for reads inside a transaction, and an optional window that sends a session's reads to the database for a set time after the session writes.
Redis is the better choice when the data is not a SQL query result. Redis caches anything the application can serialize, including API responses, rendered fragments and computed values, and Readyset caches only the results of SELECT queries.
Redis is also the better choice when the application needs control or reach that Readyset does not offer. Redis does not depend on the source of the data, because the application decides what goes into it, so it can cache results from any datastore or from none. Readyset supports PostgreSQL and MySQL. Redis lets the application set a TTL per key and delete a key immediately on a write, while a Readyset pull-based cache is bounded by its TTL and refresh settings.
Redis costs less infrastructure to add when it is already running. A team with Redis in production for sessions and queues can add a cache to that instance without deploying another service, while Readyset is a new service to deploy and size.
Readyset has limits of its own. A pull-based cache holds results in memory and runs the query on the database at every refresh, so an aggressive refresh on a high-cardinality cache can raise database load. Readyset does not cache locking reads such as SELECT ... FOR UPDATE.
Yes, for everything that is not a SQL query result. Sessions, rate limiting, leaderboards, pub/sub, streams and application-computed data stay on Redis.
Job queues are the clearest example of Redis work that is not caching. Frameworks such as Laravel offer Redis as a queue backend for background jobs, and a job queue is a different feature from caching, one that Readyset does not touch. A team whose framework uses Redis for queues keeps Redis whether or not it moves its query cache.
Readyset and Redis run side by side. As a Redis cache alternative, Readyset takes SQL query result caching, and Redis keeps every other job.
Start by pointing a staging copy of the application at Readyset by changing the connection string. Readyset proxies every query, and SHOW PROXIED QUERIES lists them with a readyset_supported column that says whether each one can be cached.
Then create a pull-based cache for the queries you want, one at a time, and set the TTL and refresh interval from what each query's data tolerates. A query whose results must reflect writes immediately can use a push-based cache or stay uncached.
Pull-based cache entries are keyed on the query and its parameters, so cache only queries whose results are safe for every client that connects to Readyset. Pull-based caches support Postgres row-level security by keying on the session state its policies read. Automatic caching rejects queries that reference session or user variables, and a cache created explicitly is cached as written.
Check the first caches against the database before moving more queries. The query support page lists what each cache type accepts on MySQL and PostgreSQL.
We see Redis and Readyset as tools for different jobs, and what separates them is who owns the cache. Our recommendation is to keep Redis for sessions, queues, rate limits and application data, and to use Readyset's pull-based cache for SQL query results. Look at SHOW PROXIED QUERIES first and cache the queries that repeat most.
To go through your own PostgreSQL or MySQL workload with the Readyset team, book a Readyset demo.