lua_redis
This module contains helper functions for working with Redis
Functions:
Function | Description |
---|---|
try_load_redis_servers(options, rspamd_config, no_fallback) |
Tries to load redis servers from the specified options object. |
lua_redis.parse_redis_server(module_name, module_opts, no_fallback) |
Extracts Redis server settings from configuration. |
lua_redis.redis_make_request(task, redis_params, key, is_write, callback, command, args) |
Sends a request to Redis. |
lua_redis.redis_make_request_taskless(ev_base, redis_params, key, is_write, callback, command, args) |
Sends a request to Redis in context where task is not available for some specific use-cases. |
lua_redis.request(redis_params, attrs, req) |
Sends a request to Redis synchronously with coroutines or asynchronously using. |
lua_redis.connect(redis_params, attrs) |
Connects to Redis synchronously with coroutines or asynchronously using a callback (modern API). |
lua_redis.register_prefix(prefix, module, description[, optional]) |
Register new redis prefix for documentation purposes. |
lua_redis.prefixes([mname]) |
Returns prefixes for specific module (or all prefixes). |
The module lua_redis
defines the following functions.
try_load_redis_servers(options, rspamd_config, no_fallback)
Tries to load redis servers from the specified options
object.
Returns redis_params
table or nil in case of failure
Parameters:
No parameters
Returns:
No return
Back to module description.
lua_redis.parse_redis_server(module_name, module_opts, no_fallback)
Extracts Redis server settings from configuration
Parameters:
module_name {string}
: name of module to get settings formodule_opts {table}
: settings for module or nil
to fetch them from configurationno_fallback {boolean}
: should be true
if global settings must not be usedReturns:
{table}
: redis server settingsBack to module description.
lua_redis.redis_make_request(task, redis_params, key, is_write, callback, command, args)
Sends a request to Redis
Parameters:
task {rspamd_task}
: task objectredis_params {table}
: redis configuration in format returned by lua_redis.parse_redis_server()key {string}
: key to use for shardingis_write {boolean}
: should be true
if we are performing a write operatingcallback {function}
: callback function (first parameter is error if applicable, second is a 2D array (table))command {string}
: Redis command to runargs {table}
: Numerically indexed table containing arguments for commandReturns:
No return
Back to module description.
lua_redis.redis_make_request_taskless(ev_base, redis_params, key, is_write, callback, command, args)
Sends a request to Redis in context where task
is not available for some specific use-cases
Identical to redis_make_request() except in that first parameter is an event base
object
Parameters:
No parameters
Returns:
No return
Back to module description.
lua_redis.request(redis_params, attrs, req)
Sends a request to Redis synchronously with coroutines or asynchronously using a callback (modern API)
Parameters:
redis_params {no type}
: a table of redis server parametersattrs {no type}
: a table of redis request attributes (e.g. task, or ev_base + cfg + session)req {no type}
: a table of request: a command + command optionsReturns:
{result,data/connection,address}
: boolean result, connection object in case of async request and results if using coroutines, redis server addressBack to module description.
lua_redis.connect(redis_params, attrs)
Connects to Redis synchronously with coroutines or asynchronously using a callback (modern API)
Parameters:
redis_params {no type}
: a table of redis server parametersattrs {no type}
: a table of redis request attributes (e.g. task, or ev_base + cfg + session)Returns:
{result,connection,address}
: boolean result, connection object, redis server addressBack to module description.
lua_redis.register_prefix(prefix, module, description[, optional])
Register new redis prefix for documentation purposes
Parameters:
prefix {string}
: string prefixmodule {string}
: module namedescription {string}
: prefix descriptionoptional {table}
: optional kv pairs (e.g. pattern)Returns:
No return
Back to module description.
lua_redis.prefixes([mname])
Returns prefixes for specific module (or all prefixes). Returns a table prefix -> table
Parameters:
No parameters
Returns:
No return
Back to module description.
Back to top.