Method .cache(timeout) in QuerySet
|Reported by:||Marinho Brandão||Owned by:||Marinho Brandão|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||semente@…, ross@…, msaelices@…, ramusus@…||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I made these changes in the QuerySet and sql.Query classes in the database component of newforms-admin branch.
I added a new method called .cache(timeout) to use like we use filter(), exclude(), select_related(), etc. that if used, enable the sql.Query class to stores the SQL query result in the cache.
This improved my systems very well, because using it, I avoid to make several queries with the same SQL sentence in the same time from the database. As we know, memory is faster than database/filesystem, so, if you use memcached or locmem backends, is probably that you can can enhance your system using this method.
As my english is the best, I published a snippet that can clear for who not understand correctly what I meant: http://www.djangosnippets.org/snippets/777/
Change History (25)
comment:3 Changed 9 years ago by
|Owner:||changed from nobody to Marinho Brandão|
|Status:||new → assigned|
comment:11 Changed 8 years ago by
|Triage Stage:||Accepted → Design decision needed|