redis_ts provides a small trait with extension functions for the redis crate to allow working with redis time series data that can be installed as a redis module. Time series commands are available as synchronous and asynchronous versions.
The crate is called redis_ts
and you can depend on it via cargo. You will
also need redis in your dependencies.
ini
[dependencies]
redis = "0.19.0"
redis_ts = "0.3.0"
Or via git:
ini
[dependencies.redis_ts]
git = "https://github.com/tompro/redis_ts.git"
With async feature inherited from the redis crate (either: 'async-std-comp' or 'tokio-comp):
ini
[dependencies]
redis = "0.19.0"
redis_ts = { version = "0.3.0", features = ['tokio-comp'] }
## Synchronous usage
To enable redis time series commands you simply load the redis_ts::TsCommands into the scope. All redis time series commands will then be available on your redis connection.
```rust use redis::Commands; use redis_ts::{TsCommands, TsOptions};
let client = redis::Client::open("redis://127.0.0.1/")?; let mut con = client.get_connection()?;
let :() = con.tscreate("my_ts", TsOptions::default())?; ```
## Asynchronous usage
To enable redis time series async commands you simply load the redis_ts::TsAsyncCommands into the scope. All redis time series commands will then be available on your async redis connection.
```rust use redis::AsyncCommands; use redis_ts::{AsyncTsCommands, TsOptions};
let client = redis::Client::open("redis://127.0.0.1/")?; let mut con = client.getasyncconnection().await?;
let :() = con.tscreate("my_ts", TsOptions::default()).await?; ```