redif

Crates.ioredif
lib.rsredif
version0.1.1
sourcesrc
created_at2017-10-26 07:41:35.601814
updated_at2017-11-03 08:45:41.147437
descriptionRedis protocol server Framework
homepagehttps://github.com/kuerant/redif-rs
repositoryhttps://github.com/kuerant/redif-rs
max_upload_size
id36987
size42,501
(kuerant)

documentation

https://github.com/kuerant/redif-rs

README

redif-rs

Redis protocol server Framework in Rust

Redif is a framework, it talks the data transport in redis protocol, and call user provided Handler to handle the request. User should implement Handler trait, and invoke Redif with redif::run( port, handler).

For example


extern crate redif;

use std::sync::{Arc,Mutex};
use redif::{Value, Handler};

// implement Handler trait
struct Store {
    kv : HashMap<String, String>,
}

impl Handler for Store {

    fn handle(&mut self, data: &Value) -> Option<Value> {
		/// ...
	}

}


fn main() {

    let port = 4344u16;
    let store = Store::new();
    let handler = Arc::new(Mutex::new(store));

    // call redif::run() with port and handler
    if let Err(ref e) = redif::run( port, handler.clone() ) {
        error!("ERROR {}", e);
        std::process::exit(1);
    }
}

examples/simple.rs is a simple demo.

Commit count: 7

cargo fmt