Code

Opened 7 years ago

Closed 7 years ago

#3241 closed enhancement (wontfix)

[patch] memcached backend can't use keys containing spaces

Reported by: recalcitrare@… Owned by: jacob
Component: Core (Cache system) Version: master
Severity: normal Keywords: memcached
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I wanted to use memcached to cache pages whose URLs contain spaces, but was told 'Client.MemcachedKeyCharacterError, "Control characters not allowed"'. The memcache module refuses to use keys longer than 250 characters or containing "control characters", which it defines as anything with a decimal ASCII code below 33 -- which includes the space character.

So the attached memcached backend uses a hash (SHA1) of the URL as the cache key as necessary. Seems to perform OK in my limited seat-of-the-pants usage; I suppose urllib.quote might be faster, but wouldn't help with long URLs.

Attachments (1)

memcached.py (1.6 KB) - added by recalcitrare@… 7 years ago.
revision of memcached backend that can handle keys > 250 characters or containing spaces

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by recalcitrare@…

revision of memcached backend that can handle keys > 250 characters or containing spaces

comment:1 Changed 7 years ago by recalcitrare@…

  • Summary changed from memcached backend can't use keys containing spaces to [patch] memcached backend can't use keys containing spaces

comment:2 Changed 7 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 Changed 7 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

This is something you'll need to deal with in your client code; hashing the cache keys makes it nearly impossible to introspect the cache.

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.