fix: get cache correctly from redis
This commit is contained in:
parent
eb7e5503de
commit
8a58774359
4 changed files with 14 additions and 7 deletions
|
@ -35,8 +35,9 @@ pub async fn get(
|
|||
if let Ok(cache_hit) = app_state
|
||||
.get_cache_key(format!("{guild_uuid}_channels"))
|
||||
.await
|
||||
&& let Ok(channels) = serde_json::from_str::<Vec<Channel>>(&cache_hit)
|
||||
{
|
||||
return Ok((StatusCode::OK, Json(cache_hit)).into_response());
|
||||
return Ok((StatusCode::OK, Json(channels)).into_response());
|
||||
}
|
||||
|
||||
let channels = Channel::fetch_all(&app_state.pool, guild_uuid).await?;
|
||||
|
|
|
@ -35,8 +35,10 @@ pub async fn get(
|
|||
|
||||
Member::check_membership(&mut conn, uuid, guild_uuid).await?;
|
||||
|
||||
if let Ok(cache_hit) = app_state.get_cache_key(format!("{guild_uuid}_roles")).await {
|
||||
return Ok((StatusCode::OK, Json(cache_hit)).into_response());
|
||||
if let Ok(cache_hit) = app_state.get_cache_key(format!("{guild_uuid}_roles")).await
|
||||
&& let Ok(roles) = serde_json::from_str::<Vec<Role>>(&cache_hit)
|
||||
{
|
||||
return Ok((StatusCode::OK, Json(roles)).into_response());
|
||||
}
|
||||
|
||||
let roles = Role::fetch_all(&mut conn, guild_uuid).await?;
|
||||
|
|
|
@ -27,8 +27,10 @@ pub async fn get(
|
|||
|
||||
Member::check_membership(&mut conn, uuid, guild_uuid).await?;
|
||||
|
||||
if let Ok(cache_hit) = app_state.get_cache_key(format!("{role_uuid}")).await {
|
||||
return Ok((StatusCode::OK, Json(cache_hit)).into_response());
|
||||
if let Ok(cache_hit) = app_state.get_cache_key(format!("{role_uuid}")).await
|
||||
&& let Ok(role) = serde_json::from_str::<Role>(&cache_hit)
|
||||
{
|
||||
return Ok((StatusCode::OK, Json(role)).into_response());
|
||||
}
|
||||
|
||||
let role = Role::fetch_one(&mut conn, role_uuid).await?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue