Memoize in the shell
So, one day at work, me and my fried David were complaining about how slow requests to AWS can be, using the cli, and what a pain it is to iterate on a slow feedback loop. David remarked, "I wish we could memoize this". That stopped me in my tracks. "Yeah, why don't we?"
A flash later, we had memoize as a shell function.
It doesn't have any testing rig, but if it did, there are a few cases we have considered:
-
The return code,
stdoutandstderrshould all be replicated. -
The whole of the command is used in the cache key. That is, invokations with different arguments are cached separately.
-
Waiting to read something from either
stdoutorstderrbefore reading the other should not block. -
Cache entries can be cleared individually.
-
Cache can age out with a TTL
-
Removing empty files in cache does not affect results
-
Removing cache completely does not cause a crash