You've already forked AstralRinth
forked from didirus/AstralRinth
PG/RedisPool configuration/o11y improvements (#5032)
* Don't retain Redis connections while doing database queries * Optional REDIS_WAIT_TIMEOUT_MS * Attach more data to CacheTimeout errrors * Fix locks_released * Fmt * Set default REDIS_WAIT_TIMEOUT_MS to 15s * Fix lint * Close Redis connections idle for > 5 minutes * Exponential backoff on cache spin lock
This commit is contained in:
committed by
GitHub
parent
ea17534f77
commit
ff222aa168
@@ -209,17 +209,19 @@ impl DBSession {
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres>,
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
{
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
let res = redis
|
||||
.get_deserialized_from_json::<Vec<i64>>(
|
||||
SESSIONS_USERS_NAMESPACE,
|
||||
&user_id.0.to_string(),
|
||||
)
|
||||
.await?;
|
||||
let res = redis
|
||||
.get_deserialized_from_json::<Vec<i64>>(
|
||||
SESSIONS_USERS_NAMESPACE,
|
||||
&user_id.0.to_string(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
if let Some(res) = res {
|
||||
return Ok(res.into_iter().map(DBSessionId).collect());
|
||||
if let Some(res) = res {
|
||||
return Ok(res.into_iter().map(DBSessionId).collect());
|
||||
}
|
||||
}
|
||||
|
||||
use futures::TryStreamExt;
|
||||
@@ -237,6 +239,8 @@ impl DBSession {
|
||||
.try_collect::<Vec<DBSessionId>>()
|
||||
.await?;
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis
|
||||
.set_serialized_to_json(
|
||||
SESSIONS_USERS_NAMESPACE,
|
||||
|
||||
Reference in New Issue
Block a user