MCPcopy Create free account
hub / github.com/base/base / get

Method get

crates/proof/rpc/src/cache.rs:116–138  ·  view source on GitHub ↗

Gets a value from the cache, returning `None` if not present.

(&self, key: &K)

Source from the content-addressed store, hash-verified

114
115 /// Gets a value from the cache, returning `None` if not present.
116 pub async fn get(&self, key: &K) -> Option<V> {
117 let value = self.cache.get(key).await;
118 if value.is_some() {
119 self.metrics.record_hit();
120 if let Some(name) = &self.hits_metric_name {
121 metrics::counter!(
122 Arc::clone(name),
123 "cache_name" => Arc::clone(&self.name),
124 )
125 .increment(1);
126 }
127 } else {
128 self.metrics.record_miss();
129 if let Some(name) = &self.misses_metric_name {
130 metrics::counter!(
131 Arc::clone(name),
132 "cache_name" => Arc::clone(&self.name),
133 )
134 .increment(1);
135 }
136 }
137 value
138 }
139
140 /// Inserts a value into the cache.
141 pub async fn insert(&self, key: K, value: V) {

Callers 15

resolve_addressFunction · 0.45
print_cycle_tableMethod · 0.45
wait_for_rpcFunction · 0.45
mainFunction · 0.45
render_reportFunction · 0.45
find_open_issueFunction · 0.45
build_reverse_depsFunction · 0.45
transitive_rdepsFunction · 0.45
resetMethod · 0.45
trie_node_by_hashMethod · 0.45
bytecode_by_hashMethod · 0.45

Calls 4

is_someMethod · 0.80
record_hitMethod · 0.80
record_missMethod · 0.80
incrementMethod · 0.45

Tested by 6

trie_node_by_hashMethod · 0.36
bytecode_by_hashMethod · 0.36
header_by_hashMethod · 0.36
request_idFunction · 0.36
trie_node_by_hashMethod · 0.36