注册

注册要在发生某些事件时运行的函数管道。

Redis 堆栈
public java.lang.String register()

public java.lang.String register​(ExecutionMode mode)

public java.lang.String register​(
    ExecutionMode mode, 
    gears.operations.OnRegisteredOperation onRegister, 
    gears.operations.OnUnregisteredOperation onUnregistered)

Registers the pipeline of functions to run when certain events occur. The registered functions will run each time the event occurs.

Execution modes:

Name Description
ASYNC Runs asynchronously on all of the shards.
ASYNC_LOCAL Runs asynchronously but only on the current shard that generated the event.
SYNC Runs synchronously only on the same shard that generated the event.
Note:
If you call register() without specifying an execution mode, it will default to ASYNC.

Parameters

Name Type Description
mode ExecutionMode The execution mode to use (ASYNC/ASYNC_LOCAL/SYNC)
onRegister OnRegisteredOperation Register callback that will be called on each shard upon register
onUnregistered OnUnregisteredOperation Unregister callback that will be called on each shard upon unregister

Returns

Returns a registration ID.

Example

GearsBuilder.CreateGearsBuilder(reader).register();