Skip to content

persistent caching #4

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

Open
lordmundi opened this issue Jun 29, 2012 · 1 comment
Open

persistent caching #4

lordmundi opened this issue Jun 29, 2012 · 1 comment

Comments

@lordmundi
Copy link

While looking at the code on github, I noticed there is automatic caching of results, with a default expiration of 5 seconds.

However, since if a web server is calling your code to populate values on a page view, won't this reload your python code on every page view? If so, I'm guessing none of the caching will stick around since I don't think you are writing it to a file or anything.

This is a request for a way to somehow have the cache persist across multiple page views on the web server. If it is possible to do this with a certain webserver config rather than modifying the code, please let me know.

I'd just like to say thanks so much for your contribution of the python-tstat code. My son and I are thinking about taking on a web controlled thermostat, and since he is learning python, we think your library might be perfect for us.

@pjennings
Copy link
Owner

The caching is intended to prevent the thermostat from receiving requests in quick succession for functions like getTime, getSetPoints, etc., which would otherwise generate multiple requests for the same address. In testing I noticed that the thermostat will stop responding if you send it requests too quickly (or more than one request at a time). The caching is supposed to help with that.

I think most people probably use this library to grab the data and store it in a database, and then pull the data from the database for the frontend. I suppose you could turn the cache expiration way up and use this library more directly as a frontend.

I don't really have time to test it at the moment, but I added a branch called "persistent_cache" that will read the cache from a file at startup and write it to the file every time it is updated. Please feel free to fork this and make changes to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants