robcowart commented :
I can also see external storage as a useful feature. However my use-case isn’t transactions. It is related to allowing multiple instances of a load balanced application to share cached values.
Consider two instances of an app, A & B.
- Instance A receives a work unit for which it must execute an expensive task to determine a required value (V). It caches V in its local ristretto cache so that it must not be redetermined if needed again.
- Instance B then receives a work unit for which it also needs V. Since it isn’t in its local ristretto cache and there is no mechanism to get the value from A, it must also perform the expensive task to determine V.
In this scenario a multi-layer cache, which includes an external storage layer would be useful. The parallel here is CPU caching, which includes L1, L2 and L3 caches. Each layer sacrifices some performance for greater durability and capacity.
Returning to the example above, a ristretto “L2” cache which resides on external storage (e.g. Redis) would help.
- Instance A receives a work unit for which it must execute an expensive task to determine a related value (V). It caches V in its local ristretto cache so that it must not be redetermined if needed again. In the background the ristretto cache also writes V to an external Redis instance.
- Instance B then receives a work unit for which it also needs V. It first checks its local ristretto cache. Ristretto doesn’t have it in memory, so it issues a query to its “L2” (the external Redis instance) where it is able to successfully fetch V, and avoids the expensive task for determining V.