Earlier quoted context omitted.
0 - Caching antipattern 101: key = calculate_cache_key() if not cache.has(key): data = expensive_calculation() cache.store(key, data) else: data = cache.get(key)
This is interesting because this is generally how I implement caching! What would pseudocode look like for a non-antipattern?
This gets more complicated if you have a distributed cache and/or distributed application servers. The typical solution there is to allow at most one computation per process/device.