-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement file based cache #60
base: master
Are you sure you want to change the base?
Conversation
Add two configuration options: tileCacheFolder, tileCacheLifetime
We used this adjustment in our script now since 7 days without problems. |
Hey @swarnat Thank you for the PR, testing and sharing your experience with it. I haven't had time to test it yet, but I will do it asap and merge it into ✌️ |
Hi @swarnat! That's a really nice idea and simple implementation 👍 A question I have is how you manage cleanup of expired items in the cache if they're not requested again? Do you run some sort of cron job outside staticmaps to periodically cleanup expired cache items? |
We implemented a nodejs webserver around this library, we will share soon. We also did benchmarks about compression, but the little lower filesize wasn't useful in our case, because the longer response time was more important. |
Maybe the automated cache cleanup should be optional. If you would have a huge cache it would've had bad impact to the map generation performance and running an external script to perform the cache cleanup could be more efficiant. |
Merge from upstream
Add Docs for Implement tileCacheAutoPurge Add Docs for calling clearCache manually
After some time I come back to this PR. Sorry for delay. |
After even more time (sorry for that), I reviewed your PR. First of all thanks for the implementation and testing. It is straightforward and effective improvement: Benchmark
Questions
|
implement getTileCacheHits to verify during tests
Because to write the cache file can be an asynchronous function and only would extend processing time of first call when synchronous
Done: 8a2339b
Sorry. Updated |
True, But maybe you should write the file to a temporary filename and rename it in the |
Ah wait. But it wouldn't fix the fact that the 2nd request to that file has no info that it is currently in state "writing". So on top of that you also had to check if there's already the same temp. file name available and you had to wait until this file is renamed. Don't know if we're over engineering things here. |
We used this feature now since february for ~10 maps every day and do not recognize any errors. I also learned something new from your last commit: Async functions don't needs to return an extra Promise. We also just upload our application to github, so everybody can quickly setup a nodejs / docker deployment with your library: |
We heavily improved the performance of this library by using an optional file based cache.
We decided against the usage of cache system, provided by got package, because there is no compatible cache provider.
And data is big enough to be stored in file.
I marked this as WIP, because this it currently in test phase of our software.
We also will do some additional benchmarking with compression of cache, and maybe some auto purge.
And you are really fast with merging. :) Thanks for your work!