Implement redis clustering (#5189)

Co-authored-by: Jai Agrawal <geometrically@Jais-MacBook-Pro.local>
This commit is contained in:
Jai Agrawal
2026-01-23 04:51:17 -08:00
committed by GitHub
parent 5c29a8c7dd
commit fb1050e409
13 changed files with 200 additions and 124 deletions

View File

@@ -120,7 +120,12 @@ impl AnalyticsQueue {
.arg(
views_keys
.iter()
.map(|x| format!("{}:{}-{}", VIEWS_NAMESPACE, x.0, x.1))
.map(|x| {
format!(
"{}:{{ns:{VIEWS_NAMESPACE}}}:{}-{}",
VIEWS_NAMESPACE, x.0, x.1
)
})
.collect::<Vec<_>>(),
)
.query_async::<Vec<Option<u32>>>(&mut redis)
@@ -152,7 +157,10 @@ impl AnalyticsQueue {
};
pipe.atomic().set_ex(
format!("{}:{}-{}", VIEWS_NAMESPACE, key.0, key.1),
format!(
"{}:{{ns:{VIEWS_NAMESPACE}}}:{}-{}",
VIEWS_NAMESPACE, key.0, key.1
),
new_count,
6 * 60 * 60,
);
@@ -195,7 +203,10 @@ impl AnalyticsQueue {
downloads_keys
.iter()
.map(|x| {
format!("{}:{}-{}", DOWNLOADS_NAMESPACE, x.0, x.1)
format!(
"{}:{{ns:{VIEWS_NAMESPACE}}}:{}-{}",
DOWNLOADS_NAMESPACE, x.0, x.1
)
})
.collect::<Vec<_>>(),
)
@@ -219,7 +230,10 @@ impl AnalyticsQueue {
};
pipe.atomic().set_ex(
format!("{}:{}-{}", DOWNLOADS_NAMESPACE, key.0, key.1),
format!(
"{}:{{ns:{VIEWS_NAMESPACE}}}:{}-{}",
DOWNLOADS_NAMESPACE, key.0, key.1
),
new_count,
6 * 60 * 60,
);