Comments (13)
.get() referring to cacheops is ok, it's the way it works. The rest is
definitely a bug.
It would be great if you created a test for it.
from django-cacheops.
I've created a pull request for test cases.
Here is what I faced when I was creating tests. Your test_requirements installed Django 1.6 and I get the ProductReview.DoesNotExist for my second .get
. However when I downgraded Django to 1.4.10 I didn't get any exception!
I hope it helps you to fix this bug.
Cheers.
from django-cacheops.
That works as expected (DoesNotExist on second get) on both Django 1.6 and 1.4.10.
Also, it's not really a test. There should be asserts there or something.
from django-cacheops.
And no .get() queries all the table. There should be something wrong with your django.
from django-cacheops.
(cacheops)Aykuts-MacBook-Air:django-cacheops aykutozat$ pip freeze
Django==1.4.10
ipdb==0.8
ipython==1.1.0
redis==2.8.0
simplejson==3.3.1
wsgiref==0.1.2
(cacheops)Aykuts-MacBook-Air:django-cacheops aykutozat$ ./run_tests.py
Creating test database for alias 'default'...
Creating test database for alias 'slave'...
.....................xxx..x...
----------------------------------------------------------------------
Ran 30 tests in 0.544s
OK (expected failures=4)
Destroying test database for alias 'default'...
Destroying test database for alias 'slave'...
(cacheops)Aykuts-MacBook-Air:django-cacheops aykutozat$ pip freeze
Django==1.6
ipdb==0.8
ipython==1.1.0
redis==2.8.0
simplejson==3.3.1
wsgiref==0.1.2
(cacheops)Aykuts-MacBook-Air:django-cacheops aykutozat$ ./run_tests.py
Creating test database for alias 'default'...
Creating test database for alias 'slave'...
...................E.xxx..x...
======================================================================
ERROR: test_62 (tests.tests.IssueTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/aykutozat/cacheops/django-cacheops/tests/tests.py", line 202, in test_62
p2.reviews.get(status=0) # returns the same result with p.reviews.get(status=0)
File "/Users/aykutozat/cacheops/django-cacheops/cacheops/query.py", line 524, in get
return self.get_queryset().inplace().get(*args, **kwargs)
File "/Users/aykutozat/cacheops/django-cacheops/cacheops/query.py", line 416, in get
return qs._no_monkey.get(qs, *args, **kwargs)
File "/Users/aykutozat/cacheops/lib/python2.7/site-packages/django/db/models/query.py", line 307, in get
self.model._meta.object_name)
DoesNotExist: ProductReview matching query does not exist.
----------------------------------------------------------------------
Ran 30 tests in 1.077s
FAILED (errors=1, expected failures=4)
Destroying test database for alias 'default'...
Destroying test database for alias 'slave'...
I don't understand what can possibly wrong with my Django? I install it with pip like you or everyone else.
from django-cacheops.
Try clearing pip download cache and then create a fresh virtualenv. I just did, everything behaves as expected.
from django-cacheops.
Also, create virtualenv without access to global packages.
from django-cacheops.
Here I created a fresh virtualenv, cloned cacheops, applied my tests. Installed your requirements without pip cache. Then uninstalled Django 1.6. Installed Django 1.4.10 from source. I still didn't get the exception.
(cacheops)Aykuts-MacBook-Air:django-cacheops aykutozat$ pip freeze
Django==1.4.10
redis==2.8.0
simplejson==3.3.1
wsgiref==0.1.2
(cacheops)Aykuts-MacBook-Air:django-cacheops aykutozat$ ./run_tests.py
Creating test database for alias 'default'...
Creating test database for alias 'slave'...
.....................xxx..x...
----------------------------------------------------------------------
Ran 30 tests in 0.542s
OK (expected failures=4)
Destroying test database for alias 'default'...
Destroying test database for alias 'slave'...
from django-cacheops.
Maybe Django source, from which you install 1.4.10 is altered.
from django-cacheops.
Try installing 1.4.9 and 1.5.0
from django-cacheops.
I still didn't get any error for 1.4.9 and 1.5.0. I even tried at one of my co-workers PC who uses ubuntu, guess what I didn't get any error again.
It is clear that there is a bug here.
from django-cacheops.
Hi Suor,
I've opened a pull request which is a fix for this issue.
And let me please tell you the problem. You set the get_queryset
to get_query_set method of ManagerMixin. So this means Manager has two methods now, get_queryset
and get_query_set
. And whenever you call .get_queryset
from your .get
or others, it actually calls your custom method and doesn't override default get_query_set
.
Therefore, you need to call .get_query_set
of django's "Manager" from .get_queryset
of your "ManagerMixin". And it solves the bug.
Thanks.
from django-cacheops.
Looks like my environment was dirty, sorry for that confusion. Anyway it's fixed now thanks to you.
from django-cacheops.
Related Issues (20)
- Support for funcy > 2 HOT 2
- Issue with Lua script that manages cache keys HOT 2
- Elevated and spiky request time with `CACHEOPS_INSIDEOUT` HOT 1
- 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
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.