Skip to content

Instantly share code, notes, and snippets.

@vovagalchenko
vovagalchenko / LookasideCache.java
Last active Nov 15, 2020
Lookaside cache read operation pseudocode. Please don't mistake this for production-ready code. It's not. The aim of the snippet is to illustrate the high level flow of the algorithm.
View LookasideCache.java
public class LookasideCache {
private CacheCluster cacheCluster;
private LeaseUtils leaseUtils;
/**
* Read a value utilizing a lookaside cache.
*
* @param key whose value is to be returned
* @param sourceOfTruthComputation the function to use to fetch the value from the
* source of truth if that should become necessary.