johnny-cache
johnny-cache copied to clipboard
multi table optimisation
In cache.py:KeyHandler.get_multi_generation(...) a key is formed by mixing the current generations of all the tables involved. This means that if any of the tables are updated a new key will be derived.
What doesn't make sense to me is that this key is then used in a key -> generation lookup. Why not just use this derived value (currently called key) as the generation for that combination of tables? It would save a get and possibly a set operation.
In other words if we have table A with generation Ag1 and table B with generation Bg1 then it is sufficient for the generation of (A, B) to be calculated as (Ag1 ^ Bg1) and there is no need to store/lookup a random value using (Ag1 ^ Bg1) as the key.
Or am I missing something?
I have tried making this change and it works well as far as I can tell:
https://github.com/dgym/johnny-cache/commit/52f2591c57625e3ebff457d7b6f597f58f5b6a95