Skip to content

Commit

Permalink
Update get client count
Browse files Browse the repository at this point in the history
  • Loading branch information
kasugamirai committed Oct 14, 2024
1 parent 437f1e0 commit 89b27be
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions websocket/crates/infra/src/persistence/redis/redis_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ impl RedisClientTrait for RedisClient {
key: &str,
value: &T,
) -> Result<(), RedisClientError> {
let serialized = serde_json::to_string(value)?;
let mut connection = self.connection.lock().await;
let _: () = connection.set(key, serde_json::to_string(value)?).await?;
connection.set::<_, _, ()>(key, serialized).await?;
Ok(())
}

Expand Down Expand Up @@ -120,13 +121,13 @@ impl RedisClientTrait for RedisClient {

async fn get_client_count(&self) -> Result<usize, RedisClientError> {
let mut connection = self.connection.lock().await;
let client_list: Vec<String> = redis::cmd("CLIENT")
let client_list: String = redis::cmd("CLIENT")
.arg("LIST")
.arg("TYPE")
.arg("normal")
.query_async(&mut *connection)
.await?;
Ok(client_list.len())
Ok(client_list.lines().count())
}
}

Expand Down

0 comments on commit 89b27be

Please sign in to comment.