mirror of
https://github.com/modrinth/code.git
synced 2026-08-30 11:36:05 +00:00
feat(labrinth): Redis Cluster (#6771)
* chore(labrinth): bump to redis 1.4.1 * feat(labrinth): redis cluster * chore: cleanup * feat(labrinth): cache locking * fix(labrinth): clippy * chore(labrinth): cleanup env, remove postcard support * chore(ci): fix test env for labrinth * chore(labrinth): bump all key versions * chore(labrinth): improve redis key identities handling * chore(labrinth): simplify deadline handling * chore(labrinth): remove unused lease tracking * chore(labrinth): remove distributed cache locking for now * chore(labrinth): improve redis backend init error * feat(labrinth): expose redis read replica strategy * chore(ci): remove other connection mode tests * chore: split xredis crate * feat(xredis): primaries routing * chore: tombi fmt * chore: clippy * chore: update query cache
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
use crate::database::PgTransaction;
|
||||
use crate::database::redis::RedisPool;
|
||||
use ariadne::ids::base62_impl::parse_base62;
|
||||
use dashmap::DashMap;
|
||||
use futures::TryStreamExt;
|
||||
use std::fmt::{Debug, Display};
|
||||
use std::hash::Hash;
|
||||
use xredis::RedisPool;
|
||||
|
||||
use super::{DBTeamMember, ids::*};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
const ORGANIZATIONS_NAMESPACE: &str = "organizations:v1";
|
||||
const ORGANIZATIONS_TITLES_NAMESPACE: &str = "organizations_titles:v1";
|
||||
const ORGANIZATIONS_NAMESPACE: &str = "organizations:v3";
|
||||
const ORGANIZATIONS_TITLES_NAMESPACE: &str = "organizations_titles:v3";
|
||||
|
||||
#[derive(Deserialize, Serialize, Clone, Debug)]
|
||||
/// An organization of users who together control one or more projects and organizations.
|
||||
@@ -159,7 +159,9 @@ impl DBOrganization {
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(organizations)
|
||||
Ok::<_, crate::database::models::DatabaseError>(
|
||||
organizations,
|
||||
)
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
@@ -256,16 +258,17 @@ impl DBOrganization {
|
||||
redis: &RedisPool,
|
||||
) -> Result<(), super::DatabaseError> {
|
||||
let mut redis = redis.connect().await?;
|
||||
|
||||
redis
|
||||
.delete_many([
|
||||
(ORGANIZATIONS_NAMESPACE, Some(id.0.to_string())),
|
||||
(
|
||||
let mut keys = vec![redis.key().entity(ORGANIZATIONS_NAMESPACE, id.0)];
|
||||
if let Some(slug) = slug {
|
||||
keys.push(
|
||||
redis.key().entity(
|
||||
ORGANIZATIONS_TITLES_NAMESPACE,
|
||||
slug.map(|x| x.to_lowercase()),
|
||||
slug.to_lowercase(),
|
||||
),
|
||||
])
|
||||
.await?;
|
||||
);
|
||||
}
|
||||
|
||||
redis.delete_many(&keys).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user