Proposal: Drop model menu.models.CacheKey

56 views
Skip to first unread message

Jacob Rief

unread,
Nov 22, 2019, 6:09:08 AM11/22/19
to django CMS developers
During my work on a faster implementation of the MenuRenderer, I came across the model menu.models.MenuCache.
This models in my opinion doesn't make any sense at all, and could be dropped. It has been added in 2010 without
referring to any issue or pull request. The only possible explanation I have found is this commit message:
"First try to have a process-safe caching mechanism for menu trees".

A possible intention of this model could be to lock the cache 's bucket, while some data is computed to be stored at it, so that
not more than one thread/process can for instance rebuild the menu tree. If that's the original intention, then the current implementation
however does not work as expected, one would have to use SELECT FOR UPDATE to block the resource, ie. the chosen
cache-key. It's somehow weird, to use a relational database to block a resource inside a memory cache.

Another approach would be to use Distributed locks with Redis. There is a Python implementation for it, which however means
that we force django-CMS users to exclusively rely on Redis caching, rather than say memcached or other caching mechanisms.

Therefore my proposal is to completely drop that table and remove the code using it. It just makes harm, with no evident benefit.
The worst scenario which could happen (but happens anyway), is that two threads/processes compute the menu tree at the same
time and the later one wins in that sense, that it is the one which writes its computed data to the cache. So, that's not a real problem.

What do other core developers of django-CMS think about this proposal?

– Jacob

Mark Walker

unread,
Nov 22, 2019, 4:07:43 PM11/22/19
to django CMS developers
I'd be keen for this as well.

I first became aware of this table when running multiple instances of a CMS site which lead to me raising this issue; https://github.com/divio/django-cms/issues/6298

I can't think of a sane scenario which would need cache keys to be stored in the database.

Peter Farrell

unread,
Nov 22, 2019, 4:14:45 PM11/22/19
to django-cms...@googlegroups.com
I'd be keen on this as well.

--
Message URL: https://groups.google.com/d/msg/django-cms-developers/topic-id/message-id
Unsubscribe: send a message to django-cms-devel...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "django CMS developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-cms-devel...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/django-cms-developers/3bab9aa2-1eac-4513-b449-69680c3fc024%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages