doRedis icon indicating copy to clipboard operation
doRedis copied to clipboard

Example code for setGetTask contains a typo

Open thomaskisler opened this issue 8 years ago • 3 comments

The setGetTask example that can be found in the pdf documentation on CRAN contains a typoe. I very much hope, that setting getTask is still supported. I want to use to control the order of execution in a parallel foreach loop (which definitely would be awesome).

The example gives the following code example and imho misses a " and a closing bracket). Or maybe I am missing something.

getTask <- function(queue, job_id, ...) { key <- sprintf(" redisEval("local x=redis.call('hkeys',KEYS[1])[1]; if x==nil then return nil end; local ans=redis.call('hget',KEYS[1],x); redis.call('hdel',KEYS[1],x);i return ans",key) }

Many thanks for the great package though, this saved me already many hours of work and is much appreciated.

thomaskisler avatar Jan 16 '17 09:01 thomaskisler

When comparing the default_getTask method, I guess now, that the "sprintf" line is truncated at the first percent sign and should look something like the following:

getTaskDefault <- function ( queue , job_id , ...) { key <- sprintf("%s:%s",queue, job_id) return(redisEval("local x=redis.call('hkeys',KEYS[1])[1]; if x==nil then return nil end; local ans=redis.call('hget',KEYS[1],x); redis.call('set', KEYS[1] .. '.start.' .. x, x); redis.call('hdel',KEYS[1],x); return ans",key)) }

thomaskisler avatar Jan 18 '17 11:01 thomaskisler

As it still needs to be corrected in the documentation, I of course leave it open.

thomaskisler avatar Jan 18 '17 11:01 thomaskisler

thanks, traveling but will fix this weekend

On 1/18/17, thomaskisler [email protected] wrote:

As it still needs to be corrected in the documentation, I of course leave it open.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/bwlewis/doRedis/issues/44#issuecomment-273454545

bwlewis avatar Jan 20 '17 17:01 bwlewis