-
Notifications
You must be signed in to change notification settings - Fork 83
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
Django 1.6 support #40
Comments
See also #36. |
Working on it this weekend, we have about 20 failing tests so there's a lot of new issues with 1.6, particularly around transaction management, so it may be a bit. |
Any updates on this? |
bump? |
There's been fixes to branch django-1.6 that brings the test failures to about 3, all transaction based. I haven't had a chance to revisit it though, or to test multi-db. Pull requests are welcome if you can fix the failing tests or test multi-db. :) Once all are complete we can do a release, until then I wouldn't feel comfortable releasing it for a production environment. jmoiron's travelling and I'll be traveling next week, so I can say it won't be this weekend otherwise, perhaps by Christmas. |
Status please !! Happy Holidays!! |
Not sure if good practice to do but: +1 Keep up the good work |
Has anybody taken a look at how to handle the new Atomic class in django-1.6 (https://github.com/django/django/blob/master/django/db/transaction.py#L221)? It doesn't use the public api that johnny patches, but uses the connection directly. |
Status? |
Created a branch at https://github.com/gdub/johnny-cache/tree/django-1.6 that has start of some tests for the new Atomic class. With a patched django 1.6 (https://github.com/gdub/django/tree/1.6.x-atomic-patch):
If the Django patch can make it into the 1.7 release, then perhaps johnny-cache can skip support for Django 1.6 and jump to supporting 1.7 instead. Note: I've pushed the tox setup I was using for the above tests to https://github.com/gdub/johnny-cache/tree/tox-configs |
@gdub Where is the Django ticket for merging your pull request? Do I understand it correctly that this is what's blocking further progress on this ticket? |
(Author of Django's new transaction handling here.) I had a quick look at johnny/transaction.py. It seems that johnny-caches uses savepoints and relies on the fact that Django doesn't use them. This isn't true anymore in Django 1.6. I suspect mixing nested I'm not convinced the changes suggested in Django are a good idea, they make the implementation less consistent in order to support monkey-patching that may break the guarantees of |
The Django ticket, and linked pull request, is here: https://code.djangoproject.com/ticket/22802 @aaugustin, Not sure on the comment about johnny using savepoints and relies on the fact of Django not using them. johnny/transaction.py still calls the original django functions, wrapping them to do some of its own house-cleaning with its cache store. I'm also not a fan of the monkey patching, though I also think it shows that Django does not provide easy enough hooks to into the transaction behavior. Unless the base Django database classes provided a way to mixin a transaction-management class or a way to specify a desired class via a database option, one would have to create a set of python packages and class hierarchy to parallel each existing database backend. Perhaps one of the johnny-cache authors would have more insight into the decisions made, or possible long-term solutions that would make extension easier. I threw out some ideas in the comments of the linked Django ticket. |
@gdub Since that ticket was wontfixed I guess the way forward is to find a way to let people install a custom database backend. Is providing patched versions of the existing backends such a big deal? I see the configuration options needed to be: DATABASES = {
'default': {
'ENGINE': johnny.backends.mysql',
...
}
} ... and a mixin for people that want to use johnny cache for their own database backend. |
Hi all. What is the status of Django 1.6 support. From browsing online, it seems like johnny-cache is being used with Django 1.6, and also issue #29 is more evidence of that. So is johnny an option for 1.6? If yes, does the django-1.6 branch (10 month old) have to be used? The alternatives are django-cache-machine and django-cacheops which are nice, but they either don't appropriately invalidate on INSERT, don't use Django's cache settings, or Redis only. Hopefully I have not misunderstood these alternatives. Any input on this matter is appreciated. |
Thanks Amir, We too are pondering whether on this as well and would really love to know of a branch that is working effectively with MySQL and Django >= 1.6. For the reasons you state I am unwilling to move - I am doing some benchmarks to see if I can bring straight MySQL caching to the performance that Johnny Cache can produce but haven't achieved it as of now. |
As far as I know, there is still a lot of cache invalidation issues with Django 1.6. |
I'm currently writing a successor for johnny-cache, built from scratch for Django 1.6 & 1.7. I just finished a prototype for Redis only, it works well! It consists in 105 lines of code and you just have to add a line to I’ll share it as soon as possible! |
Would love to see it when your ready @BertrandBordage ! |
Me too. Frankly I do not have the time, energy, or desire to maintain johnny-cache properly, and that's been clear for a while. I have dragged my feet in admitting it and trying to find a maintainer, which is a major failing on my part. In the interim:
It's about time for a rewrite which doesn't have these burdens. If it can be made compatible with the interface and strict guarantees johnny has set out in the past, I don't mind handing over the project and pypi repos. Otherwise, I will accept any patches that improve compatibility and hand out repos access to people willing to patch it. |
@jmoiron Yes, the project wanted to be compatible with too many versions of Django & Python. It became a bit of a mess and now it’s too hard to clean everything, even after hours of work. However, I really want to thank you for sharing johnny-cache, it helped me a lot in the past three years! And so, I started a new project called django-cachalot! I copied on johnny-cache the idea of monkey patching the ORM. Everyone can give it a try, but please don’t use it in production before version 1.0! |
@BertrandBordage How do you plan to handle the atomic problem? |
@vishen First easy solution, simply avoid caching read queries when But we can cache what happens in transaction, we simply need to use a local caching (using a dict for reads and a set of invalidated tables) for each atomic block. When an atomic block fails, we delete the dict & set, otherwise we merge them to the local cache of the parent atomic block. If there's no parent atomic block, we "commit" by applying changes to the real cache backend. All this is quite easy using I’ll work on this tonight. |
The transaction issue was a bit more complicated than I thought. What I said above didn’t work exactly as expected. Instead of relying on So yes, django-cachalot properly handles transactions since a few minutes :) |
Hey @BertrandBordage I spent this morning reviewing your code and I like where your head is. I have a couple questions though. At the expense of looking like a idiot I'll ask them because I really want a solid successor to johnny. It's not entirely clear how you are performing cache invalidation. Perhaps you could explain this a bit to me (us). To summarize the creating of a cache key (on a read) you do this
To invalidate a cache key (on a write) you do this
But here is where my confusion steps in (perhaps it redis only but) when you do a I suppose I'm in error on this but could you clarify this a bit. Edit: It looks like you are storing two queries one to hold the query and another to store the queries whch are under the table. Is this correct? Thanks |
@rh0dium, could you ask your question on the django-cachalot Google group? We’re a bit off-topic now. |
We have been using johnny-cache heavily for models that don't change often and this issue was preventing us from upgrading django. So went ahead and implemented an alternative that uses custom model manager and querysets, see https://github.com/vijaykatam/django-cache-manager. We are currently swapping out johnny-cache in favor of this. |
Thanks for sharing, we could start some kind of guideline for READMEs in django projects, since there are so many majors versions around and alive, something like:
Anyway this idea may be way too off topic, we stopped using johnny cache in my current project after upgrading to 1.6 and I will wait just a bit before trying a new cache solution again. Hope your project get mature and stable. :) |
@cabello good point, will add django versions. |
It would be great to have support for Django 1.6. Most obvious change is that
django.core.cache.backends.memcached.CacheClass
was renamedBaseMemcachedCache
. Not sure about the rest.The text was updated successfully, but these errors were encountered: