Better control of memory cache in tastypie

168 views
Skip to first unread message

David Tsai

unread,
Jul 31, 2012, 8:07:06 PM7/31/12
to django-...@googlegroups.com
Hi Guys,

As you know, by default in tastypie, when an object is deleted or
updated, it will not do anything in the cache which causes the issue
of cache inconsistency when we use SimpleCache(). The only thing we
can do is just wait until the cache is expired.

We are building a social network site, the data in the cache must be
real time, so I implemented a new method ``delete`` in the
SimpleCache(), and I hooked it up to the cached_obj_delete and
cached_obj_update such that when an object is updated or deleted, the
cache will be destroyed. See
https://github.com/toastdriven/django-tastypie/pull/578

On the other hand, ``list`` operation in tastypie doesn't fully
utilize memory cache, and the implementation of
``cached_obj_get_list`` (which is not used by default) doesn't allow
fine-grained cache control; therefore, I have another implementation
which uses the cache of detail endpoint, and I try to generate all the
cache_keys for the list and then use cache.get_many() to populate the
bundle. It speeds up our site a lot, and I'm wondering how many people
are interested in this feature. If there are lots of people interested
in, I'll spend some time to get the code generalized and write the
documented and unittest in order to be merged.

Sincerely,

David Tsai
Stanford University
-----------------------------------
Web: http://www.dbtsai.com
Phone : +1-650-383-8392

Joe Sateriani

unread,
May 30, 2017, 2:59:15 PM5/30/17
to Tastypie, dbt...@dbtsai.com
Hello @David

I am now running on the same issue, and got a bit surprised that Tastypie didn't really take this into consideration !
I looked up on StackOverflow and I didn't find any clue, and I even posted a  question, but no echos. I joind Google Groups just to thank you for your initiative ! And also to see if there is any progress or news so far about this issue !

Best regards.
Reply all
Reply to author
Forward
0 new messages