4 releases

99.99.99 Apr 28, 2024
2.0.7 Apr 28, 2024
0.1.3 Dec 10, 2024
0.1.2 Sep 12, 2024
0.1.0 Apr 30, 2024

#1160 in Database interfaces

Download history 345/week @ 2024-09-12 259/week @ 2024-09-19 197/week @ 2024-09-26 202/week @ 2024-10-03 161/week @ 2024-10-10 249/week @ 2024-10-17 115/week @ 2024-10-24 126/week @ 2024-10-31 59/week @ 2024-11-07 111/week @ 2024-11-14 160/week @ 2024-11-21 291/week @ 2024-11-28 471/week @ 2024-12-05

1,048 downloads per month

BSD-3-Clause

270KB
6K SLoC

license Releases crates.io docs CircleCI

valkeymodule-rs

This crate provides an idiomatic Rust API for the Valkey Modules API. It allows writing Valkey modules in Rust, without needing to use raw pointers or unsafe code. See here for the most recent API documentation.

This repo was forked from redismodule-rs. We appreciate the contributions of the original authors.

Running the example module

  1. Install Rust
  2. Install Valkey, most likely using your favorite package manager (Homebrew on Mac, APT or YUM on Linux)
  3. Run cargo build --example hello
  4. Start a valkey server with the hello module
    • Linux: valkey-server --loadmodule ./target/debug/examples/libhello.so
    • Mac: valkey-server --loadmodule ./target/debug/examples/libhello.dylib
  5. Open a valkey-cli, and run HELLO.MUL 31 11.

Writing your own module

See the examples directory for some sample modules.

To optionally enter the System.alloc code paths in alloc.rs specify this in Cargo.toml of your module:

[features]
enable-system-alloc = ["valkey-module/system-alloc"]

For unit tests with System.alloc use this:

cargo test --features enable-system-alloc

For integration tests with ValkeyAlloc use this:

cargo test

This crate tries to provide high-level wrappers around the standard Valkey Modules API, while preserving the API's basic concepts. Therefore, following the Valkeyi Modules API documentation will be mostly relevant here as well.

Dependencies

~7–15MB
~218K SLoC