MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / insert_if_generation

Method insert_if_generation

packages/server/src/api/routes.rs:147–174  ·  view source on GitHub ↗
(
        &self,
        key: AccessibilitySnapshotCacheKey,
        snapshot: &Value,
        generation: u64,
    )

Source from the content-addressed store, hash-verified

145 }
146
147 fn insert_if_generation(
148 &self,
149 key: AccessibilitySnapshotCacheKey,
150 snapshot: &Value,
151 generation: u64,
152 ) {
153 if !cacheable_accessibility_snapshot(snapshot) {
154 return;
155 }
156 let generations = self
157 .generations
158 .lock()
159 .unwrap_or_else(|poisoned| poisoned.into_inner());
160 if generations.get(&key.udid).copied().unwrap_or(0) != generation {
161 return;
162 }
163 let mut cache = self
164 .inner
165 .lock()
166 .unwrap_or_else(|poisoned| poisoned.into_inner());
167 cache.insert(
168 key,
169 CachedAccessibilitySnapshot {
170 cached_at: Instant::now(),
171 snapshot: snapshot.clone(),
172 },
173 );
174 }
175
176 fn latest_interactive(&self, udid: &str) -> Option<Value> {
177 let mut cache = self

Callers 3

insertMethod · 0.80
warm_accessibility_cacheFunction · 0.80

Calls 4

insertMethod · 0.80
getMethod · 0.65
cloneMethod · 0.65

Tested by

no test coverage detected