lj_rust/examples/populate_redis.rs

36 lines
974 B
Rust
Raw Normal View History

/**
# Populate Redis Example
**This script simulates the redis content provided by the LJ Python / web tool**
$ cargo run --example populate_redis
**/
2023-07-17 20:44:06 +00:00
use redis::{
//RedisResult,
Client,
Commands,
Connection,
2023-07-17 20:44:06 +00:00
};
fn do_something() -> redis::RedisResult<()> {
let client = Client::open("redis://127.0.0.1/")?;
let mut con: Connection = client.get_connection()?;
let _ = con.set("/clientkey", "/pl/0/")?;
let _ = con.set(
"/EDH/0",
"[[1.0, 0.0, 0.0],\n [ 0.0, 1.0, 0.0],\n [ 0.0, 0.0, 1.0]]",
)?;
let _ = con.set("/kpps/0", "5000")?;
let _ = con.set("/intensity/0", "255")?;
let _ = con.set("/pl/0/0", "[(1000, 2000, 0), (1000, 1000, 65535), (2000, 1000, 65535), (2000, 2000, 65535), (1000, 2000, 65535)]")?;
Ok(())
2023-07-17 20:44:06 +00:00
}
2023-07-17 20:44:06 +00:00
fn main() {
match do_something() {
Err(err) => println!("Something wrong occured: {:?}", err),
Ok(..) => println!("Successfully inserted content in Redis"),
}
2023-07-17 20:44:06 +00:00
}