Implement caching system
Katsute opened this issue · 5 comments
Prerequisites
If all checks are not passed then the request will be closed
- I have checked that no other similar feature request already exists
- The feature request makes sense for the project
Proposal
Describe the feature that should be added
Implement caching for liveload
https://crunchify.com/how-to-create-a-simple-in-memory-cache-in-java-lightweight-cache/
Reasoning
Explain why this feature should be added
Efficiency and memory.
When a file is first accessed:
- create a long with the expiry
- set the timer to a lower number if its lower than current
When the timer reached end:
- remove any files that passed expiry
- if lowest expiry passed reset to next lowest timer
If a file is reaccesed:
- reset expiry for that file
Update file cache when the last modified time changes.
A cache byte loading option could require a file cache adapter (and throw illegal args otherwise).
Parameter can be long millis or double and TimeUnit.
Instead of a timer instead only clear cache on an exchange.
Have a long for the closest file expiry and then iterate through each file to clear bytes.
After read set expiry to -1 then use that to determine if to read file when accessed again.
A timer will not be used because this would introduce some thread instability with multiple threads.