Strong Consistency in Cache Augmented SQL Systems (the IQ Framework)
Shahram Ghandeharizadeh, Jason Yap & Hieu Nguyen · ACM Middleware 2014
A paper presentation for CSCI 585 Database Systems at USC, given in class on Monday, November 16, 2026. The paper is by Shahram Ghandeharizadeh, Jason Yap and Hieu Nguyen (ACM Middleware 2014). This page is my summary and my reading of it.
The setting
A cache augmented SQL (CASQL) system puts a key-value store (KVS) such as memcached in front of a relational database. Looking up a cached query result is much cheaper than running the query, which suits read-heavy workloads such as social networking. The hard part is keeping cached values correct when the database changes. The paper defines a session as at most one RDBMS transaction plus one or more KVS operations, and asks for the ACID properties at the granularity of sessions.
Applications keep the cache current in one of three ways: invalidate (delete the affected key), refresh (read the key, modify it in the application, write it back), or incremental update (send only the change, such as an append).

Where stale data comes from
- Invalidate with snapshot isolation. A writer deletes the key; a reader then misses, queries a snapshot from before the writer commits, and puts that old value in the cache after the writer has committed. Nothing removes it afterwards. Moving the delete after the commit does not help, because the reader's write can still land later.
- Compare-and-swap does not know the commit order. Starting from 100, one session adds 50 and another multiplies by 10. The database ends at (100 + 50) × 10 = 1,500, while the cache, with both cas calls succeeding, ends at 100 × 10 + 50 = 1,050.
- Dirty reads and incremental races. Updating the cache before commit exposes values that never existed if the transaction aborts, and an append can be lost or applied twice.
Measured with Twitter's Twemcache under the BG social networking benchmark, up to 8.3% of reads returned stale data.

The I and Q leases
The fix needs no change to the database. The KVS gains two leases:
- Inhibit (I), for readers. On a cache miss the KVS grants at most one I lease per key. That reader queries the database and fills the key; other readers back off and retry.
- Quarantine (Q), for writers. A writer takes a Q lease on every key it will change before its transaction commits, applies the cache change after commit, and then releases the lease. A Q lease always voids an existing I lease, so the reader's stale write is ignored.
| Request | Existing I lease | Existing Q lease |
|---|---|---|
| Reader asks for I | Back off and retry | Back off and retry |
| Writer asks for Q | Grant Q, void the I lease | Invalidate: grant (deleting twice is harmless). Refresh or incremental: abort the requester |
Q leases are exclusive for refresh and incremental update because the cache cannot know which writer the database will order first, so it aborts one and makes it retry. A session acquires its leases before commit and releases them after, much like two-phase locking. Unlike locks, leases expire, so a crashed application server cannot hold one forever, and a conflict returns an abort instead of blocking, which keeps the scheme free of deadlocks.
An optimization defers the delete until after commit. Readers in the meantime get a cache hit on the old value and are serialized before the writer, while the writer is forced to miss on its own key so it sees its own update. The paper calls this period the re-arrangement window.
Implementation and results
- Built by extending Twemcache 2.5.3 (IQ-Server) and the Whalin memcached Java client 2.6.1 (IQ-Client), with ten commands, including QaRead and SaR (quarantine-and-read, swap-and-release) for refresh, and IQ-δ, Commit and Abort for incremental updates. Lease tokens are managed by the client and are invisible to the developer.
- Evaluated with BG on 10K- and 100K-member social graphs and write mixes of 0.1%, 1% and 10%. Stale reads drop from up to 8.3% to 0% in every configuration.
- Throughput (SoAR, the highest rate at which 95% of actions finish within 100 ms) is essentially unchanged: about 29,200–31,500 actions per second with and without IQ.
- Taking Q leases before the transaction starts is simpler but can starve a writer under load (up to 77 restarts). Taking them during the transaction keeps the maximum at 9.
My take
The appeal is how little it asks for: two leases in the cache, no change to the database, and stale reads go to zero at negligible cost, with a clear account of each race it closes. The limits are the ones the authors state. A session may contain at most one RDBMS transaction, and the guarantees hold within a single data center, not across geo-replicated deployments. Multi-transaction sessions and testing on LinkBench and RUBiS are left as future work.