Comments (6)
You can try using queryset.cache(lock=True)
.
from django-cacheops.
So, does this issue that I mentioned indeed exist? I will try to reproduce the problem and attempt to solve it using lock = True
. THX
from django-cacheops.
I don't understand what did this mean "Thread B invalidates the cache but doesn’t actually clear anything".
About whether there issue exists I am not sure, you can try to create a test using before_after library - there is already one test using it.
from django-cacheops.
I don't understand what did this mean "Thread B invalidates the cache but doesn’t actually clear anything".
About whether there issue exists I am not sure, you can try to create a test using before_after library - there is already one test using it.
Because when Thread B invalidates the cache, Thread A's cache write operation hasn't completed yet. At that point, the cache is actually empty (assuming the initial state is empty).
In summary, could it happen that Thread B's cache invalidation occurs before Thread A writes to the cache, in a concurrent scenario?
I will try to use before_after
lib to reproduce this issue. Thanks for your advice.
from django-cacheops.
I reproduced this issue using a concurrent approach.
I tried to solve it using lock = True
, but it didn’t completely resolve the issue. Some requests still couldn’t retrieve data and resulted in errors. However, it doesn’t seem to cause the previous irrecoverable problem.
By using the invalidate_obj
approach mentioned above, it seems to have completely resolved the issue, and there are no more errors.
from django-cacheops.
Actually looking a little bit more at problematic issue, it has concurrency issues outside of cache - the code does not have a transaction, doesn't set ._for_write = True
for initial .get()
. Using .get_or_create()
should solve this problem too.
from django-cacheops.
Related Issues (20)
- in combination with django-tenant-schemas, "public" tables caching is not working HOT 1
- INSIDEOUT doesn't work with Elasticache HOT 5
- features to prevent cache stampede HOT 3
- django-cacheops not working with Django version 4 HOT 3
- Unable to disable cacheops primitives HOT 1
- Memory problem on django test init HOT 7
- DB migrations are being cached even after using setting migrations timeout to zero HOT 6
- Issue with signals (ManagerMixin._post_save() missing 1 required positional argument: 'using') HOT 3
- Question on @cached_as HOT 1
- Redis getting called too many times in a single API call. HOT 3
- Django Admin not invalidating cache on save HOT 4
- Nik
- Support for cache invalidation on `bulk_update()` method HOT 3
- AWS Elasticache Redis Serverless Implementation is raising AttributeError HOT 6
- cache wrongly set to empty list for get query (when accessing a foreignkey field) HOT 15
- conj keys always have -1 as expiration in redis 7 HOT 3
- Are we supporting model translation with django cacheops ? HOT 5
- Delete operation fails with -OOM command not allowed when used memory > 'maxmemory'. HOT 2
- How to enable caching for 'views' only HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-cacheops.