top | item 23450835

(no title)

gsu2 | 5 years ago

Why not force memcached clients to use the binary protocol instead of the ASCII protocol?

The length check would still be necessary, but spaces (and other arbitrary bytes) would no longer break things.

discuss

order

danpalmer|5 years ago

It's not really possible in Django to force this as each library will implement that in a different way (or may not even support the binary protocol). Django adding validation is easy, unlikely to cause issues, and makes all usage safe unless the user explicitly overrides the behaviour.

Plus, Django actually implements these checks for non-Memcached backends, raising warnings if keys aren't Memcached compatible. This is done because very often in local development users might run the "local memory" cache backend, which is just a Python dict. In this case they probably want to know that what they're doing won't work when it gets to Memcached in production.