Skip to content

Commit

Permalink
Merge pull request #1163 from AppFlowy-IO/trim-awareness-on-drop
Browse files Browse the repository at this point in the history
fix: trim awareness when collab group is dropped
  • Loading branch information
khorshuheng authored Jan 15, 2025
2 parents 4921845 + 8c6a657 commit c3bba77
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 756 deletions.
25 changes: 23 additions & 2 deletions libs/collab-stream/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl CollabRedisStream {
}
}

pub async fn prune_stream(
pub async fn prune_update_stream(
&self,
stream_key: &str,
mut message_id: MessageId,
Expand All @@ -201,11 +201,32 @@ impl CollabRedisStream {
let count = usize::from_redis_value(&value)?;
drop(conn);
tracing::debug!(
"pruned redis stream `{}` <= `{}` ({} objects)",
"pruned redis update stream `{}` <= `{}` ({} objects)",
stream_key,
message_id,
count
);
Ok(count)
}

pub async fn prune_awareness_stream(&self, stream_key: &str) -> Result<(), StreamError> {
let mut conn = self.connection_manager.clone();
let value = conn
.send_packed_command(
redis::cmd("XTRIM")
.arg(stream_key)
.arg("MAXLEN")
.arg("=")
.arg(0),
)
.await?;
let count = usize::from_redis_value(&value)?;
drop(conn);
tracing::debug!(
"pruned redis awareness stream {} ({} objects)",
stream_key,
count
);
Ok(())
}
}
Loading

0 comments on commit c3bba77

Please sign in to comment.