Building the update client
Our update function takes the following signature:
// nanoservices/user-session-cache/cache-client/src/lib.rs
#[derive(Debug)]
pub enum UserSessionStatus {
Ok(i32),
Refresh
}
pub async fn update(address: &str, user_id: &str)
-> Result<UserSessionStatus, NanoServiceError> {
let mut con = get_connnection(address).await?;
. . .
}
The command is defined with the code below:
// nanoservices/user-session-cache/cache-client/src/lib.rs
let result = con
.req_packed_command(
&redis::cmd("update.set")
.arg(user_id)
.clone(),
)
.await.map_err(|e|{
NanoServiceError::new(
e.to_string(),
NanoServiceErrorStatus::Unknown
)
})?;
With the result, we can inspect the string, returning a status depending on the response string with the code below:
// nanoservices/user-session-cache/cache-client/src/lib.rs
let result_string = unpack_result_string...