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)
| 28 | |
| 29 | /// Build a tenant-scoped composite key `"{tenant}:{a}:{b}"` using thread-local buffer. |
| 30 | fn 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}"`. |
| 45 | pub(super) fn with_tenant_key4<R>( |
no test coverage detected