Code

Opened 5 years ago

Closed 5 years ago

Last modified 5 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: UI/UX:

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 :)

Attachments (0)

Change History (5)

comment:1 Changed 5 years ago by munhitsu

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

Third party issue: cmemcache.

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

comment:2 follow-up: Changed 5 years ago by seifert

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.

comment:3 in reply to: ↑ 2 ; follow-up: Changed 5 years ago by munhitsu

Replying to seifert:

Which python memcached module are you using?

comment:4 in reply to: ↑ 3 ; follow-up: Changed 5 years ago by seifert

Replying to munhitsu:

I use python-memcached.

comment:5 in reply to: ↑ 4 Changed 5 years ago by Sundance

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?

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.