perf(get): reuse reader paths and lock namespaces (#6015)

Co-authored-by: heihutu <heihutu@gmail.com>
This commit is contained in:
houseme
2026-08-13 01:37:25 +08:00
committed by GitHub
parent 019e80a218
commit 59494d5089
7 changed files with 104 additions and 41 deletions
+6 -1
View File
@@ -479,7 +479,7 @@ pub struct DistributedLock {
/// Lock clients for this namespace
clients: Vec<Arc<dyn LockClient>>,
/// Namespace identifier
namespace: String,
namespace: Arc<str>,
/// Quorum size for exclusive/write operations
quorum: usize,
}
@@ -496,6 +496,11 @@ struct LockAcquireQuorumResult {
impl DistributedLock {
/// Create new distributed lock
pub fn new(namespace: String, clients: Vec<Arc<dyn LockClient>>, quorum: usize) -> Self {
Self::new_shared(namespace.into(), clients, quorum)
}
/// Create a distributed lock that shares an existing namespace allocation.
pub(crate) fn new_shared(namespace: Arc<str>, clients: Vec<Arc<dyn LockClient>>, quorum: usize) -> Self {
let q = if clients.len() <= 1 {
1
} else {