Description Usage Arguments Details Value Note Author(s) Examples
Define a function that uniquely labels collections of tasks.
1 | setTaskLabel(fn = I)
|
fn |
A task labeling function, see details below. |
The doRedis
package organizes work into a collections of tasks called a
job. One job may contain several uniquely identified task collections, and jobs
themselves are uniquely identified. The task collections are labeled by the
taskLabel
function.
The taskLabel
function must take exactly one argument, a single integer
value. Its output must be coerceable into a character string and the function
must be injective.
The default getTask
function removes tasks in the order that they appear
in the hash table. Custom getTask
functions can be defined often in
association with custom taskLabel
functions. The custom functions can
instruct Redis to perferentially dole out tasks based on network distance to
data, for example.
Nothing is returned.
All doRedis functions require network access to a Redis server (not included with the doRedis package).
B. W. Lewis <blewis@illposed.net>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Not run:
require('doRedis')
# The default getTask function defines a Redis Lua script that returns the first
# listed task or NULL:sk <- function(queue, job_id, ...)
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)
}
setTaskLabel(fn = I)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.