Cache any function (with its arguments)
Please see original snippet for commentary, all I did was add the caching of the arguments. http://www.djangosnippets.org/snippets/109/
- cache
- function
- threading
- threads
- thread
Please see original snippet for commentary, all I did was add the caching of the arguments. http://www.djangosnippets.org/snippets/109/
A decorator similar to `cache_page`, which will cache any function for any amount of time using the Django cache API. I use this to cache API calls to remote services like Flickr in my view, to prevent having to hit their servers on every request. I posted a sample function which uses the [delicious API](http://www.djangosnippets.org/snippets/110/) in the function, also. **Update**: It now also will put in a temporary 'in-process' variable (an instance of `MethodNotFinishedError`) in the cache while the function is processing. This will prevent the cache from calling the method again if it's still processing. This does not affect anything **unless you're using threads**.
2 snippets posted so far.