Skip to content

Commit d03af1b

Browse files
author
Shane Wall
committed
Format storage cache
1 parent e6fc5a7 commit d03af1b

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

crates/storage/src/cache.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ impl ByteLruCache {
148148
let gen = self.generations.peek(id).copied().unwrap_or(0);
149149
self.generations.put(*id, gen + 1);
150150
}
151-
152151
}
153152

154153
// ── CachedBackend ─────────────────────────────────────────────────────────────
@@ -407,7 +406,10 @@ mod tests {
407406

408407
write_seg(&mut cached, 1, b"original").await;
409408
let _ = cached.read(SegmentId(1)).await.unwrap();
410-
assert!(cached.cached_bytes() > 0, "first read should populate cache");
409+
assert!(
410+
cached.cached_bytes() > 0,
411+
"first read should populate cache"
412+
);
411413

412414
// Overwrite the segment — cache must be invalidated.
413415
write_seg(&mut cached, 1, b"updated!").await;
@@ -471,7 +473,10 @@ mod tests {
471473
// The generation is now 2 (invalidated twice: once manually, once by write_seg).
472474
// Any in-flight read that captured gen=0 or gen=1 would be rejected.
473475
let result = cached.read(SegmentId(1)).await.unwrap();
474-
assert_eq!(result, b"v2", "must serve fresh data, not stale pre-write data");
476+
assert_eq!(
477+
result, b"v2",
478+
"must serve fresh data, not stale pre-write data"
479+
);
475480

476481
// Second read must hit the cache and still return v2.
477482
let result2 = cached.read(SegmentId(1)).await.unwrap();
@@ -494,7 +499,9 @@ mod tests {
494499
};
495500
let mut txn = cached.begin_txn().await.unwrap();
496501
txn.append(SegmentId(1), b"updated").await.unwrap();
497-
txn.set_segment_metadata(SegmentId(1), seg_new).await.unwrap();
502+
txn.set_segment_metadata(SegmentId(1), seg_new)
503+
.await
504+
.unwrap();
498505
txn.commit().await.unwrap();
499506

500507
// Cache should have been invalidated at commit time.

crates/storage/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use tiering::{
1717
};
1818

1919
mod cache;
20-
pub use cache::{CachedBackend, CacheInvalidatingTransaction};
20+
pub use cache::{CacheInvalidatingTransaction, CachedBackend};
2121

2222
#[cfg(all(target_os = "linux", feature = "uring"))]
2323
mod uring;

0 commit comments

Comments
 (0)