Opened 10 years ago

Closed 10 years ago

Last modified 10 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


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?

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


File "/vhost/cr3studio/cr3studio/django_site/django/django/core/cache/backends/", 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 Changed 10 years ago by munhitsu

Resolution: wontfix
Status: newclosed

Third party issue: cmemcache.

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

comment:2 Changed 10 years ago by seifert


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

I use:

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


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

It works.

comment:3 in reply to:  2 ; Changed 10 years ago by munhitsu

Replying to seifert:

Which python memcached module are you using?

comment:4 in reply to:  3 ; Changed 10 years ago by seifert

Replying to munhitsu:

I use python-memcached.

comment:5 in reply to:  4 Changed 10 years ago by Pascal Varet

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,, 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