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
@@ -156,17 +156,19 @@ impl DBPersonalAccessToken {
|
||||
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>>(
|
||||
PATS_USERS_NAMESPACE,
|
||||
&user_id.0.to_string(),
|
||||
)
|
||||
.await?;
|
||||
let res = redis
|
||||
.get_deserialized_from_json::<Vec<i64>>(
|
||||
PATS_USERS_NAMESPACE,
|
||||
&user_id.0.to_string(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
if let Some(res) = res {
|
||||
return Ok(res.into_iter().map(DBPatId).collect());
|
||||
if let Some(res) = res {
|
||||
return Ok(res.into_iter().map(DBPatId).collect());
|
||||
}
|
||||
}
|
||||
|
||||
let db_pats: Vec<DBPatId> = sqlx::query!(
|
||||
@@ -183,6 +185,8 @@ impl DBPersonalAccessToken {
|
||||
.try_collect::<Vec<DBPatId>>()
|
||||
.await?;
|
||||
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis
|
||||
.set(
|
||||
PATS_USERS_NAMESPACE,
|
||||
|
||||
Reference in New Issue
Block a user