This crate provides a custom Redis module type using Rust's FFI support.
By leveraging the ability to make custom types that Redis can utilize we can
use Rust to provide a new data structure. The
MultiMap type is akin to Redis' existing hash type with the added
benefit of storing more than one value.
I would not consider this module to be production ready at the moment. There should be more extensive unit test coverage.
Some benchmark numbers achieved by running the provided script locally:
MULTIMAP.INSERT averaged over 5 runs: 66,760 requests/s SET averaged over 5 runs: 78,672 requests/s
You must have Rust and LLVM installed in order to compile this project. The preferred way to install Rust is using the rustup tool. If you are wary of shell script installs, you can download it through brew.
brew install llvm # And `brew install rust` if you don't already have it installed. git clone https://github.com/gsquire/redis-multi-map cd redis-multi-map cargo build --release # The dynamic library will be under the target/release folder.
You can load the module in a few ways.
Directly from the command line.
redis-server --loadmodule /path/to/module.dylib # Or /path/to/module.so on Unix systems.
Using the Redis configuration file
The API is open to extending if other functionality is desired. The currently supported commands are as follows:
MULTIMAP.INSERT KEY MAP_KEY MAP_VALUE...
This command returns a simple string of "OK".
MULTIMAP.VALUES KEY MAP_KEY
This command lists all values associated with
MAP_KEY. It is an array of strings.
MULTIMAP.LEN KEY MAP_KEY
This command returns the length of values for
0 if it doesn't exist. This is an integer response.
MULTIMAP.DEL KEY MAP_KEY
This command deletes
KEY. It is an integer response of
MAP_KEY did not exist and
1 if it did.
Thanks to redis-cell for providing some motivation and guidance in making another module using Rust.
This code is release under an MIT license and the Redis license stored under REDIS_LICENSE.