Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Django filesystem cache thread-safe? and is it cross-process?

I need to cache lists 10MB+ size, is it safe to do it in Django filesystem cache?

Or is there a better way to do it?

like image 761
Bob Avatar asked Jan 29 '26 02:01

Bob


1 Answers

I would examine carefully the Python DiskCache.

Django is Python’s most popular web framework and ships with several caching backends. Unfortunately the file-based cache in Django is essentially broken. The culling method is random and large caches repeatedly scan a cache directory which slows linearly with growth. Can you really allow it to take sixty milliseconds to store a key in a cache with a thousand items?

In Python, we can do better. And we can do it in pure-Python!

like image 120
raratiru Avatar answered Jan 31 '26 19:01

raratiru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!