pyaptly
pyaptly copied to clipboard
feat: Replace SystemStateReader.read() with lru_cache
Removes the very time intensive SystemStateReader.read()
function and use functions that directly return the variables.
Solve the caching Problem with lru_cache
, which is cleared with ...clear_cache()
whenever a respective Command
is run.
Since the Command
already has a provides
function with known_dependency_types
which pretty much exactly resembles the state variables that should be cached, I wrote a small Command.clear_caches()
function which clears caches whenever a Command has been run.
I added some provides
definitions so that it should work consistently with the cache resetting.
I also split it up into various "easier to understand" feature-separate commits - they should even run through the tests individually :) You can also read the commit notes to follow my thought process.
FWIW I don't really understand the tests all too well and am not 100% sure I didn't accidentally "break" a test. I'm also not sure if more tests would be necessary to properly test the caching... But it looks very much like my changes are correct.