Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#10168 closed (wontfix)

Can't configure memcached backend to use unix socket

Reported by: munhitsu Owned by: nobody
Component: Core (Cache system) Version: 1.0
Severity: Keywords: enhancement
Cc: mateusz@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

So far unix socket is the only way to apply access control on memcached daemon:

memcached -m 16 -s memcached.sock

At this point django expects memcached to be on "server:port".
Can you extend it to also support files?

settings.py:

CACHE_BACKEND = 'memcached://../memcached.sock/?timeout=' +str(TIMEOUT)+ '&max_entries=' +str(MAXENTRIES)

Exception:

File "/vhost/cr3studio/cr3studio/django_site/django/django/core/cache/backends/memcached.py", line 17, in __init__
    self._cache = memcache.Client(server.split(';'))
TypeError: expected "server:port" but "../memcached.sock" found

PS: you can assign it to me :)

Change History (5)

comment:1 by munhitsu, 16 years ago

Resolution: wontfix
Status: newclosed

Third party issue: cmemcache.

In fact python-memcached seems to be also affected.
Still testing.

comment:2 by seifert, 16 years ago

Try:

CACHE_BACKEND = 'memcached://unix:memcached.sock'

I use:

memcached -u nobody -s /tmp/memcached.sock -a 0777

My settings.py:

CACHE_BACKEND = 'memcached://unix:/tmp/memcached.sock'

It works.

in reply to:  2 ; comment:3 by munhitsu, 16 years ago

Replying to seifert:

Which python memcached module are you using?

in reply to:  3 ; comment:4 by seifert, 16 years ago

Replying to munhitsu:

I use python-memcached.

in reply to:  4 comment:5 by Pascal Varet, 16 years ago

Replying to seifert:

I use python-memcached.

In python-memcache 1.40, the setting you suggest fails with the following exception:

ValueError: invalid literal for int() with base 10: '/tmp/memcached.sock'

However, it does work with python-memcache 1.43, the latest at this time.

Since python-memcache consists of but one file, memcache.py, I suggest that you ship the appropriate version of this file as part of your site's code, with the sys.path properly set so that it's your shipped version that gets imported by Django rather than that of the system.

The resolution of this ticket requires no code change in Django, but the documentation should probably be updated to mention this possibility. What do you think, Django people?

Note: See TracTickets for help on using tickets.
Back to Top