MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / with_tenant_key

Function with_tenant_key

nodedb/src/engine/sparse/btree.rs:30–42  ·  view source on GitHub ↗

Build a tenant-scoped composite key `"{tenant}:{a}:{b}"` using thread-local buffer.

(tenant_id: u64, a: &str, b: &str, f: impl FnOnce(&str) -> R)

Source from the content-addressed store, hash-verified

28
29/// Build a tenant-scoped composite key `"{tenant}:{a}:{b}"` using thread-local buffer.
30fn with_tenant_key<R>(tenant_id: u64, a: &str, b: &str, f: impl FnOnce(&str) -> R) -> R {
31 KEY_BUF.with(|buf| {
32 let mut buf = buf.borrow_mut();
33 buf.clear();
34 use std::fmt::Write;
35 let _ = write!(buf, "{tenant_id}");
36 buf.push(':');
37 buf.push_str(a);
38 buf.push(':');
39 buf.push_str(b);
40 f(&buf)
41 })
42}
43
44/// Build a tenant-scoped index key `"{tenant}:{a}:{b}:{c}:{d}"`.
45pub(super) fn with_tenant_key4<R>(

Callers 6

putMethod · 0.85
put_in_txnMethod · 0.85
exists_in_txnMethod · 0.85
batch_putMethod · 0.85
getMethod · 0.85
deleteMethod · 0.85

Calls 2

clearMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected