RedisLabsModules / redismodule-rs

Rust API for Redis Modules API
BSD 3-Clause "New" or "Revised" License
270 stars 65 forks source link

Is there anyway to write custom RDB / AOF function? #126

Closed melonux closed 3 years ago

melonux commented 3 years ago

Need example. Thank you in advance.

slavak commented 3 years ago

Meir's answer on issue #115 may possibly point you in the right direction. Otherwise, could you please clarify what you're trying to do?

melonux commented 3 years ago

Yes. It is related question. I wrote a custom redis data_type based on redismodule-rs. It works on single redis node, but cannot sync data to other redis nodes in sentinel mode. I need to implement RDB / AOF for my data_type. I have read API reference, but how to write them in rust is unknown.

static MY_REDIS_TYPE: RedisType = RedisType::new(
    ...
    raw::RedisModuleTypeMethods {
        version: raw::REDISMODULE_TYPE_METHOD_VERSION as u64,
        rdb_load: None,   // It seems the binding is in bindings.rs generated by bindgen from redismodule.h
        rdb_save: None,
        aof_rewrite: None,
        free: Some(free),
gavrie commented 3 years ago

@melonux please see the RedisJSON code for an example on how to write custom RDB load/save functions in Rust: https://github.com/RedisJSON/RedisJSON/blob/master/src/redisjson.rs

melonux commented 3 years ago

many thanks.