Durably removes all entries given by `invalidate_ids` and inserts `new_local_expressions` and `new_global_expressions` into current build version. If there is a duplicate ID in both `invalidate_ids` and one of the new expressions vector, then the final value will be taken from the new expressions vector.
(
&mut self,
new_local_expressions: Vec<(GlobalId, LocalExpressions)>,
new_global_expressions: Vec<(GlobalId, GlobalExpressions)>,
invalidate_ids: BTreeSet<GlobalId>,
| 294 | /// If there is a duplicate ID in both `invalidate_ids` and one of the new expressions vector, |
| 295 | /// then the final value will be taken from the new expressions vector. |
| 296 | async fn update( |
| 297 | &mut self, |
| 298 | new_local_expressions: Vec<(GlobalId, LocalExpressions)>, |
| 299 | new_global_expressions: Vec<(GlobalId, GlobalExpressions)>, |
| 300 | invalidate_ids: BTreeSet<GlobalId>, |
| 301 | ) { |
| 302 | let mut entries = BTreeMap::new(); |
| 303 | let build_version = self.build_version.to_string(); |
| 304 | // Important to do `invalidate_ids` first, so that `new_X_expressions` overwrites duplicate |
| 305 | // keys. |
| 306 | for id in invalidate_ids { |
| 307 | entries.insert( |
| 308 | CacheKey { |
| 309 | id, |
| 310 | build_version: build_version.clone(), |
| 311 | expr_type: ExpressionType::Local, |
| 312 | }, |
| 313 | None, |
| 314 | ); |
| 315 | entries.insert( |
| 316 | CacheKey { |
| 317 | id, |
| 318 | build_version: build_version.clone(), |
| 319 | expr_type: ExpressionType::Global, |
| 320 | }, |
| 321 | None, |
| 322 | ); |
| 323 | } |
| 324 | for (id, expressions) in new_local_expressions { |
| 325 | let expressions = match bincode::serialize(&expressions) { |
| 326 | Ok(expressions) => Bytes::from(expressions), |
| 327 | Err(err) => { |
| 328 | soft_panic_or_log!( |
| 329 | "unable to serialize local expressions: {expressions:?}: {err:?}" |
| 330 | ); |
| 331 | continue; |
| 332 | } |
| 333 | }; |
| 334 | entries.insert( |
| 335 | CacheKey { |
| 336 | id, |
| 337 | build_version: build_version.clone(), |
| 338 | expr_type: ExpressionType::Local, |
| 339 | }, |
| 340 | Some(expressions), |
| 341 | ); |
| 342 | } |
| 343 | for (id, expressions) in new_global_expressions { |
| 344 | let expressions = match bincode::serialize(&expressions) { |
| 345 | Ok(expressions) => Bytes::from(expressions), |
| 346 | Err(err) => { |
| 347 | soft_panic_or_log!( |
| 348 | "unable to serialize global expressions: {expressions:?}: {err:?}" |
| 349 | ); |
| 350 | continue; |
| 351 | } |
| 352 | }; |
| 353 | entries.insert( |