setTaskLabel: setTaskLabel

Description Usage Arguments Details Value Note Author(s) Examples

View source: R/doRedis.R

Description

Define a function that uniquely labels collections of tasks.

Usage

1

Arguments

fn

A task labeling function, see details below.

Details

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.

Value

Nothing is returned.

Note

All doRedis functions require network access to a Redis server (not included with the doRedis package).

Author(s)

B. W. Lewis <blewis@illposed.net>

Examples

 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)

cloudcell/doRedis111stable documentation built on May 13, 2019, 8:02 p.m.