IQ-Twemcached implements strong consistency in Cache Augmented Database Management Systems (CADBMS) using leases. It is a fork of Twemcache version 2.5.3. It maintains all the functionalities of Twemcache and adds new commands to support strong consistency with three different strategies to update the cache: invalidate, refresh and incremental updates.
How does IQ-Twemcached provide strong consistency?
IQ-Twemcached prevents race conditions that potentially cause stale data using the following two leases:
- Inhibit lease (I lease). Granted implicitly to a read session when it observes a cache miss.
- Quarantine lease (Q lease). Granted to write sessions. The programmer must request this lease explicitly on each key that a session intends to update
, see documentation.
In the presence of changes to a data store, one may maintain the cache up to date using invalidate, refresh or incremental updates approach. The IQ framework and its implementation in IQ-Twemcached supports those approaches. With the Invalidation technique, updates to the DBMS delete the corresponding key-value pairs in the cache. With the refresh technique, once the DBMS is updated, the application retrieves the corresponding key-value pairs from the cache, updates them, and writes them back. With the incremental updates, the changes to the DBMS when there is an update occur is propagated to the cache to update the impacted key-value pairs.
Figure 1, 2 and 3 show invalidate, refresh and incremental updates with and without the IQ framework, respectively.