When I define a map in NGINX like
keyval_zone zone=session:2m timeout=1d sync state=/var/run/nginx/state/session.json;
keyval $user_id $map_session zone=session;
I can read entries in Javascript functions, provided $user_id is set, like this:
var value = r.variables.map_session;
and assign new values:
r.variables.map_session = newValue;
However, while usually one can also write variable references r.variables.foo as r.variables["foo"], this does not work for references handled by keyval mappings.
I am not sure whether this is a bug or intentional, but if you want to create a function that takes the name of a map and updates its entries (e.g., from a file or a sub-request), it would certainly come handy to be able to refer to an entry by specifying
var key = "map_" + mappingName;
r.variables[key] = newValue;
This does not work in nginx/1.15.10 (nginx-plus-r18-p1).
Cheers,
--j.