openresty / lua-resty-memcached

Lua memcached client driver for the ngx_lua based on the cosocket API
211 stars 63 forks source link

URI Escaping the key before doing a 'get' #10

Closed abdulg closed 9 years ago

abdulg commented 9 years ago

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]"

agentzh commented 9 years ago

@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.

abdulg commented 9 years ago

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.

agentzh commented 9 years ago

@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.