[][src]Crate iredismodule

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

CallFlag

Controls the Whether replicate the command

LogLevel

Redis log level

ServerEvent

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 Definitions

RResult

Result of redis comamnd call