Skip to content

Commit

Permalink
feat: Implement SyncLruCache (#5259)
Browse files Browse the repository at this point in the history
This is just a proof of concept.

Implement a cache that works from a "&" context.

- get_from_cache_or_insert - gets a value or inserts a computed value
- get_from_cache - tries to get value

TODO:
- [x] rename methods
- [x] add new methods
- [x] benchmarks
- [x] comments
- [x] add more tests.
- [x] one example of replacing real code
- [x] implement example with `lru` (done in another PR)
- [x] Use `once_cell` instead of `lazy_static!` (done in another PR).

See #5145

Was blocked by: #5512
  • Loading branch information
pmnoxx committed Dec 5, 2021
1 parent ba021df commit 45ca9e4
Show file tree
Hide file tree
Showing 8 changed files with 565 additions and 412 deletions.
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ members = [
"tools/restored-receipts-verifier",
"integration-tests",
"utils/near-rate-limiter",
"utils/near-cache",
]

[workspace.metadata.workspaces]
Expand Down
1 change: 1 addition & 0 deletions chain/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub use crate::stats::metrics;
pub use near_network_primitives::types::PeerInfo;

pub(crate) mod common;
mod network_protocol;
mod peer;
mod peer_manager;
pub mod routing;
Expand Down
Loading

0 comments on commit 45ca9e4

Please sign in to comment.