Expand description
This crate provides an idiomatic Rust API for the Redis Modules API. It allows writing Redis modules in Rust, without needing to use raw pointers or unsafe code.
§Example
use iredismodule_macros::rcmd;
use iredismodule::prelude::*;
/// Define command
#[rcmd("hello.simple", "readonly", 0, 0, 0)]
fn hello_simple(ctx: &mut Context, _args: Vec<RStr>) -> RResult {
let db = ctx.get_select_db();
Ok(db.into())
}
// Register module
define_module! {
name: "simple",
version: 1,
data_types: [],
init_funcs: [],
commands: [
hello_simple_cmd,
]
}Modules§
- block_
client - Block client implentation
- call_
reply - Handle redis call reply
- cluster
- Cluster related structs and functions
- context
- Module context
- error
- Error management
- io
- Deal with rdb and digest
- key
- A implementation of Redis key
- prelude
- The RedisModule Prelude.
- raw
- Raw ffi generated with bingen
- rtype
- Redis data type supports
- scan_
cursor - Define ScanCursor struct
- string
- Represent Redis module string
- user
- Acl user
- value
- Implement a redis module value
Macros§
- define_
module - Create a redis module will be so easy
Enums§
- Call
Flag - Controls the Whether replicate the command
- LogLevel
- Redis log level
- Server
Event - Events kind used in
Context::subscribe_to_server_event
Traits§
- FromPtr
- Generate a wrapper struct from raw ptr
- GetPtr
- Get the inner ptr from a wrapper struct
- NextArg
- Help iterator for process args
Functions§
- avoid_
replica_ traffic - Returns true if some client sent the CLIENT PAUSE command to the server or if Redis Cluster is doing a manual failover, and paused tue clients.
- get_
client_ info_ by_ id - Return information about the client with the specified ID
- get_
notify_ keyspace_ events - Get the configured bitmap of notify-keyspace-events (Could be used for additional filtering in RedisModuleNotificationFunc)
- get_
used_ memory_ ratio - Return the a number between 0 to 1 indicating the amount of memory currently used, relative to the Redis “maxmemory” configuration.
- handle_
status - Check ret return code of redis module api
- is_
module_ busy - Check whether module name is used
- latency_
add_ sample - Allows adding event to the latency monitor to be observed by the LATENCY command.
- milliseconds
- Return the current UNIX time in milliseconds.
- parse_
args - Parse the argv/argc of redis command func
- reset_
dataset - Performs similar operation to FLUSHALL, and optionally start a new AOF file (if enabled)
Type Aliases§
- RResult
- Result of redis comamnd call