Skip to content

Conversation

@m4tx
Copy link
Member

@m4tx m4tx commented Dec 24, 2025

Similarly to #432, this drops the Arc from Arc<Cache> in public APIs to make the interfaces more ergonomic and easier to use for the users.

Similarly to #432, this drops the `Arc` from `Arc<Cache>` in public APIs
to make the interfaces more ergonomic and easier to use for the users.
@m4tx m4tx changed the title refactor: Cache instead of Arc<Cache> in public APIs refactor!: Cache instead of Arc<Cache> in public APIs Dec 24, 2025
@github-actions github-actions bot added the C-lib Crate: cot (main library crate) label Dec 24, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the caching API to improve ergonomics by removing the need for users to wrap Cache in Arc. The Cache struct now internally wraps its implementation in Arc<CacheImpl>, making it directly cloneable while maintaining the same functionality.

Key changes:

  • Modified Cache to contain an Arc<CacheImpl> wrapper around the store implementation
  • Updated all public APIs that previously used Arc<Cache> to use Cache directly
  • Changed internal field accesses to go through self.inner

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
cot/src/cache.rs Refactored Cache struct to wrap CacheImpl in Arc internally, enabling direct cloning without requiring external Arc wrapping
cot/src/test.rs Updated TestRequestBuilder and TestCache to use Cache instead of Arc<Cache> in field types and return values
cot/src/project.rs Changed function signatures, type aliases, and method return types throughout to use Cache directly instead of Arc<Cache>

The refactoring is well-executed and maintains backward compatibility in functionality while improving the API ergonomics. All method implementations correctly access the inner fields through self.inner, and the change is applied consistently across all affected files.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Dec 24, 2025

🐰 Bencher Report

Brancharc-cache
Testbedgithub-ubuntu-latest
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
microseconds (µs)
(Result Δ%)
Upper Boundary
microseconds (µs)
(Limit %)
empty_router/empty_router📈 view plot
🚷 view threshold
6,178.80 µs
(+2.02%)Baseline: 6,056.57 µs
6,805.38 µs
(90.79%)
json_api/json_api📈 view plot
🚷 view threshold
1,058.10 µs
(+3.36%)Baseline: 1,023.70 µs
1,132.61 µs
(93.42%)
nested_routers/nested_routers📈 view plot
🚷 view threshold
951.87 µs
(+0.55%)Baseline: 946.70 µs
1,043.58 µs
(91.21%)
single_root_route/single_root_route📈 view plot
🚷 view threshold
910.80 µs
(+0.52%)Baseline: 906.13 µs
996.11 µs
(91.44%)
single_root_route_burst/single_root_route_burst📈 view plot
🚷 view threshold
16,620.00 µs
(-6.13%)Baseline: 17,705.59 µs
20,944.96 µs
(79.35%)
🐰 View full continuous benchmarking report in Bencher

struct CacheImpl {
#[debug("..")]
store: Arc<dyn BoxCacheStore>,
store: Box<dyn BoxCacheStore>,
Copy link
Contributor

@ElijahAhianyo ElijahAhianyo Dec 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious about this. What's the benefit of doing it this way(boxing the store in another struct and wrapping it in an Arc)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-lib Crate: cot (main library crate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants