Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #33252 -- Made cache middleware thread safe. #15044

Merged
merged 2 commits into from Nov 3, 2021

Conversation

iurisilvio
Copy link
Contributor

The caches[key] response is not thread safe. It must be called inside
the correct thread to return a new object.

https://docs.djangoproject.com/en/3.2/topics/cache/#accessing-the-cache

@iurisilvio iurisilvio force-pushed the cache-middleware-thread-safe branch 2 times, most recently from 6a19f03 to 7f0591a Compare November 1, 2021 03:02
django/middleware/cache.py Outdated Show resolved Hide resolved
@iurisilvio
Copy link
Contributor Author

I added a second commit removing the setter that I added in the first one and changing other tests to make it pass. I don't know if I'm allowed to do that.

The setter I added first was to make other tests pass, but removing this set don't break anything.

@iurisilvio iurisilvio force-pushed the cache-middleware-thread-safe branch 2 times, most recently from cae22db to 2767657 Compare November 1, 2021 04:08
tests/cache/tests.py Outdated Show resolved Hide resolved
@felixxm
Copy link
Member

felixxm commented Nov 3, 2021

@iurisilvio Thanks 👍

@felixxm felixxm force-pushed the cache-middleware-thread-safe branch from 2c2557c to b0c4e15 Compare November 3, 2021 08:10
@felixxm felixxm force-pushed the cache-middleware-thread-safe branch from b0c4e15 to 3ff7b15 Compare November 3, 2021 08:40
@felixxm felixxm merged commit 3ff7b15 into django:main Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants