openresty/lua-resty-memcached

URI Escaping the key before doing a 'get'

abdulg opened this issue · 3 comments

I ran into an issue where I could not retrieve a value from memcache. I looked at the code and the key is being uri escaped before the get. Is that required?

The key I was using is of the form: "[key_name]"

@abdulg That's not required but just for safety (otherwise special chars may blow up the memcached wire protocol requirements). You can specify an identity Lua function as the "key_transform" option values to override that. See

https://github.com/openresty/lua-resty-memcached#new

But then you must ensure no special chars used in the key yourself.

Thanks - I will do that. However, from the spec it seems that the key_transform should only strip special chars and whitespace. Escaping URI does more than required and results in changed keys.

@abdulg Yeah, URI escaping does more than necessary but it's a standard escaping method and it is also used in nginx's standard ngx_memcached module.