[Django] #30984: Cache culling

23 views
Skip to first unread message

Django

unread,
Nov 13, 2019, 12:52:04 PM11/13/19
to django-...@googlegroups.com
#30984: Cache culling
--------------------------------------------+------------------------
Reporter: Martin Ennemoser | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
--------------------------------------------+------------------------
I have an endpoint that needs very long to create a response since the
calculation of it takes very long. My approach was to cache the result in
a file cache and return the cached result to the user. From time to time I
asynchronously recalculate the result and update the cache. Since I don't
want to let the cache expire, I set the expire argument to None. The first
time, that worked well. But after a couple of hours, I found out that the
cache files were deleted randomly. Looking into the code of the
FileBasedCache class
https://github.com/django/django/blob/master/django/core/cache/backends/filebased.py
I noticed that there is a cull() method that randomly deletes my cache
files. This is horrible since my users don't get the cached results
anymore and have to wait very long until they get the calculated result.
Don't you consider this cull() method dangerous?

--
Ticket URL: <https://code.djangoproject.com/ticket/30984>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 14, 2019, 2:33:38 AM11/14/19
to django-...@googlegroups.com
#30984: Cache culling.
-------------------------------------+-------------------------------------

Reporter: Martin Ennemoser | Owner: nobody
Type: Uncategorized | Status: closed
Component: Core (Cache system) | Version: 2.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => closed
* component: Uncategorized => Core (Cache system)
* resolution: => invalid


Comment:

> I noticed that there is a cull() method that randomly deletes my cache
files. This is horrible since my users don't get the cached results
anymore and have to wait very long until they get the calculated result.
> Don't you consider this cull() method dangerous?

Cache is to cache values, and all cache system have limited capacity, so
to create a space for new values we need to remove old entries, that's why
culling is necessary. Cache backends implement their own culling strategy
(see [https://docs.djangoproject.com/en/2.2/topics/cache/#cache-arguments
documentation]). You can increase `MAX_ENTRIES`, but I think that you're
using cache in a wrong way. Nevertheless I don't see here any issue in
Django.

Closing per TicketClosingReasons/UseSupportChannels

--
Ticket URL: <https://code.djangoproject.com/ticket/30984#comment:1>

Reply all
Reply to author
Forward
0 new messages