From b04e79a3ca9b05b20b6b0664e79eb44841e5e8b7 Mon Sep 17 00:00:00 2001 From: Alexander Clouter Date: Wed, 4 Mar 2020 20:43:00 +0000 Subject: [PATCH] support commands that have a '.' (via '__') --- README.markdown | 5 +++++ lib/resty/redis.lua | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index d57b180..57d758c 100644 --- a/README.markdown +++ b/README.markdown @@ -187,6 +187,11 @@ Here are some more examples: local res, err = red:hmset("myhash", "field1", "Hello", "field2", "World") ``` +```lua + -- RedisBloom commands contain a dot (use '__' instead) + local res, err = red:cf__exists("key", "item") +``` + All these command methods returns a single result in success and `nil` otherwise. In case of errors or failures, it will also return a second value which is a string describing the error. A Redis "status reply" results in a string typed return value with the "+" prefix stripped. diff --git a/lib/resty/redis.lua b/lib/resty/redis.lua index 4ddbac3..f48d473 100644 --- a/lib/resty/redis.lua +++ b/lib/resty/redis.lua @@ -663,7 +663,7 @@ end setmetatable(_M, {__index = function(self, cmd) local method = function (self, ...) - return _do_cmd(self, cmd, ...) + return _do_cmd(self, cmd:gsub("__", "."), ...) end -- cache the lazily generated method in our