1
0

Compiler improvements (#753)

* basic redis add

* toml; reverted unnecessary changes

* merge issues

* increased test connections

---------

Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
Wyatt Verchere
2023-11-19 19:10:13 -08:00
committed by GitHub
parent e06a77af28
commit dfba6c7c91
22 changed files with 307 additions and 140 deletions

View File

@@ -134,6 +134,8 @@ impl User {
{
use futures::TryStreamExt;
let mut redis = redis.connect().await?;
if users_strings.is_empty() {
return Ok(Vec::new());
}
@@ -151,7 +153,7 @@ impl User {
user_ids.append(
&mut redis
.multi_get::<i64, _>(
.multi_get::<i64>(
USER_USERNAMES_NAMESPACE,
users_strings.iter().map(|x| x.to_string().to_lowercase()),
)
@@ -163,7 +165,7 @@ impl User {
if !user_ids.is_empty() {
let users = redis
.multi_get::<String, _>(USERS_NAMESPACE, user_ids)
.multi_get::<String>(USERS_NAMESPACE, user_ids.iter().map(|x| x.to_string()))
.await?;
for user in users {
if let Some(user) = user.and_then(|x| serde_json::from_str::<User>(&x).ok()) {
@@ -239,8 +241,8 @@ impl User {
redis
.set(
USER_USERNAMES_NAMESPACE,
user.username.to_lowercase(),
user.id.0,
&user.username.to_lowercase(),
&user.id.0.to_string(),
None,
)
.await?;
@@ -278,8 +280,13 @@ impl User {
{
use futures::stream::TryStreamExt;
let mut redis = redis.connect().await?;
let cached_projects = redis
.get_deserialized_from_json::<Vec<ProjectId>, _>(USERS_PROJECTS_NAMESPACE, user_id.0)
.get_deserialized_from_json::<Vec<ProjectId>>(
USERS_PROJECTS_NAMESPACE,
&user_id.0.to_string(),
)
.await?;
if let Some(projects) = cached_projects {
@@ -384,6 +391,8 @@ impl User {
user_ids: &[(UserId, Option<String>)],
redis: &RedisPool,
) -> Result<(), DatabaseError> {
let mut redis = redis.connect().await?;
redis
.delete_many(user_ids.iter().flat_map(|(id, username)| {
[
@@ -402,6 +411,8 @@ impl User {
user_ids: &[UserId],
redis: &RedisPool,
) -> Result<(), DatabaseError> {
let mut redis = redis.connect().await?;
redis
.delete_many(
user_ids