openresty / openresty/memc-nginx-module
Any way to make nginx return empty_gif of result with "return ..;" instead of memcache result?
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 213
- Forks
- 55
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 2
Description
Hi.
Is there any way to make nginx return empty_gif or result with "return ...;" instead of returning result received from memcache?
If this read by "agentzh", i was inspired by your slides at http://agentzh.org/misc/slides/nginx-conf-scripting/nginx-conf-scripting.html .
location ~ /app/counter/(\d+)$ {
empty_gif;
#echo_exec /safe-memc?cmd=incr&key=id$1&val=1;
echo_location_async /safe-memc?cmd=incr&key=id$1&val=1&exptime=0;
}
# (not quite) REST interface to our memcached server
location = /memc {
internal;
set $memc_cmd $arg_cmd;
set $memc_key $arg_key;
set $memc_value $arg_val;
set $memc_exptime $arg_exptime;
memc_pass memcached_upstream2;
}
# (not quite) REST interface to our memcached server
location = /safe-memc {
internal;
set $memc_cmd $arg_cmd;
set $memc_key $arg_key;
set $memc_value $arg_val;
set $memc_exptime $arg_exptime;
memc_pass memcached_upstream2;
error_page 404 @safe-memc-add-and-retry;
}
location @safe-memc-add-and-retry {
internal;
echo_location /memc?cmd=add&key=$arg_key&val=0;
echo_location /memc?$query_string;
}
I just basically use the example from http://agentzh.org/misc/slides/nginx-conf-scripting/nginx-conf-scripting.html#45 slightly modified to adopt for my case.
I want to do a simple counter here.
The only problem is that in result to /app/counter/1 and so on it return a number (the result of SET query to memcache). But i want it simply return empty_gif. I've tried various settings but can't get it working. It completely ignores empty_gif and return directivities. Can you give me an idea please?
If possible, it would be also to cool to know how to make it really async. Because now, when it returns result, it basically waits for it (otherwise it should not return anything). I want this operation to happen in background after connection close (or better request end, not sure does that really possible - to stay keepalive connection but end current request).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the nginx configuration in the issue and trace how empty_gif, return, echo_location_async, and memc_pass interact during request processing. Check the module's request lifecycle and existing directive behavior before deciding whether the requested response and background operation are supported. Done would mean documenting or implementing a clear way to return empty_gif while performing the counter update, including the request-completion behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, memcached, nginx
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100