Question

I can't figure this out, and couldn't find a solution after googling around. I'm implementing caching for my Django app.

The steps I took were:

  1. brew install libmemcache, which installed memcache as well

  2. pip install pylibmc

  3. pip install -e hg+https://jmoiron@bitbucket.org/jmoiron/johnny-cache, which installed without error.

  4. Added this to my settings.py

    CACHES = {
        'default': {
            'BACKEND': 'johnny.backends.memcached.PyLibMCCache',
            'LOCATION': ['127.0.0.1:11211'],
            'JOHNNY_CACHE': True,
        }
    }
    JOHNNY_MIDDLEWARE_KEY_PREFIX = 'product'
    
    MIDDLEWARE_CLASSES = (
        'johnny.middleware.LocalStoreClearMiddleware',
        'johnny.middleware.QueryCacheMiddleware',
        ...
    }
    

Now whenever I browse, in the console I can see things being stored in memcache, but as soon as a memcached get comes up, Caught TypeError while rendering: cannot concatenate 'str' and 'tuple' objects is thrown. Doesn't matter what command is being run, and the error is in /env/pfenv/lib/python2.7/site-packages/django/db/backends/mysql/compiler.py in resolve_columns, line 12.

There is one other SO question about this, but the selected answer is to just use a different fork of the project, which hasn't been updated and whose changes were actually merged into the master bucket almost right away. The pypi version (which I also tried) is from before the commit they claim broke things, and that one gives me the same error. This project is updated every two weeks or so and I'd like to get the benefit of other bugfixes they've released.

This should be pretty easy to implement, what am I doing wrong here?

Update

Submitted a bug report that also includes the stack trace, just in case this isn't something that I've done.

Update 2

Actually went back and flushed the cache, turned off johnny-cache, and tried just the vanilla django cache settings with pylibmc. Doesn't work, same error on every page. Tried it with python-memcache, same thing. Not sure what to look for here. Turning off caching completely, the site works just fine. Kinda need the caching though.

Update 3

Apparently this same source checked out by a coworker and installed the same way works. I have no idea what the difference is or what else to do to troubleshoot. Any suggestions?

Was it helpful?

Solution

This was never actually fixed on my machine, still not sure what the problem was. But it works as is on our deployment server and a coworker dev environment. I'm just going to leave the answer as there was something wrong with my setup, I'm assuming with the database, since I've had other random problems related to that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top