[OpenSIPS-Users] Redis EVAL calls

Donat Zenichev donat.zenichev at gmail.com
Sat Mar 14 13:42:01 EST 2020


Hi there!

I have a question regarding how to better work with redis eval
functionality.
For the current moment I'm trying to implement this using usual
cache_raw_query() function.

Here is an example of the simple eval call, that basically checks if a
value is a member of the set:
$var(script_body) = "\"local str = ARGV[1]; for i=1,str:len(),1 do if (1 ==
redis.call('sismember', 'certain_keys_set', str:sub(1,i))) then return 1;
end; end; return 0;\"";

Then I call it with:
cache_raw_query("redis:opensips", "EVAL $var(script_body) 0 $rU",
"$avp(result)");

The obstacle I've come across is that for some reason, cachedb_redis module
throws the following error:
"ERROR:cachedb_redis:redis_raw_query_send: Redis operation failure - ERR
value is not an integer or out of range"

This script works out well though, when I insert this directly into
redis-cli.

I have an idea, that this can be caused by zero "0" following the script
body.
I tried to convert zero into integer with {s.int} but this gave no result.

I also tried to escape the whole body script with {s.escape.common} but
this also didn't work out.
On the other hand, I tried to escape all semicolons, colons, single and
double quotations with a usual escape symbol "\", and this also doesn't
give any good result.

>From what I understand, this is kind of an issue related to formatting of
string I'm trying to send to the Redis server.
And if I understand this correctly, OpenSIPS does nothing else, but pass
the input string to the redisvCommand() API function. So I'm pretty
confident this has to do something with formatting.

Might be there is some known method, I need use in order to properly encode
my string (script body) before being able to send it to Redis?
For e.g. using using base64 or somewhat like that.

In any way, I appreciate all ideas on the matter!

-- 

Best regards,
Donat Zenichev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20200314/b7b0f454/attachment.html>


More information about the Users mailing list