/// /// $ cargo run --example simple_client /// use redis::{ //RedisResult, Client, Commands, Connection, }; use std::thread::sleep; use std::time::{Duration, Instant}; const SCALE: f32 = 500.0; fn do_something() -> redis::RedisResult<()> { let client = Client::open("redis://127.0.0.1/")?; let mut con: Connection = client.get_connection()?; let start = Instant::now(); loop { let elapsed = start.elapsed(); let time = 60.0 * elapsed.as_millis() as f32 / 5_000.0; let mut v: Vec<(f32, f32, u32)> = vec![]; for i in 0..128 { let a = (time + i as f32) / 128.0 * std::f32::consts::PI * 2.0; let r = 24.0 * SCALE + (a * 5.0).cos() * (10.0 * SCALE * (time / 5.0).cos()); let x = a.cos() * r; let y = a.sin() * r; let col = if i % 8 < 4 { 0x000000ff } else { 0x00ff0000 }; v.push((x, y, col)); } // println!("{:?}", v); let _ = con.set("/pl/0/0", format!("{:?}", v))?; sleep(Duration::from_millis(100)); } // Ok(()) } fn main() { _ = do_something(); }