MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / spawn_expression_cache

Method spawn_expression_cache

src/catalog/src/expr_cache.rs:390–422  ·  view source on GitHub ↗

Spawns a task responsible for managing the expression cache. See [`ExpressionCache::open`]. Returns a handle to interact with the cache and the initial contents of the cache.

(
        config: ExpressionCacheConfig,
    )

Source from the content-addressed store, hash-verified

388 ///
389 /// Returns a handle to interact with the cache and the initial contents of the cache.
390 pub async fn spawn_expression_cache(
391 config: ExpressionCacheConfig,
392 ) -> (
393 Self,
394 BTreeMap<GlobalId, LocalExpressions>,
395 BTreeMap<GlobalId, GlobalExpressions>,
396 ) {
397 let (mut cache, local_expressions, global_expressions) =
398 ExpressionCache::open(config).await;
399 let (tx, mut rx) = mpsc::unbounded_channel();
400 spawn(|| "expression-cache-task", async move {
401 while let Some(op) = rx.recv().await {
402 match op {
403 CacheOperation::Update {
404 new_local_expressions,
405 new_global_expressions,
406 invalidate_ids,
407 trigger: _trigger,
408 } => {
409 cache
410 .update(
411 new_local_expressions,
412 new_global_expressions,
413 invalidate_ids,
414 )
415 .await
416 }
417 }
418 }
419 });
420
421 (Self { tx }, local_expressions, global_expressions)
422 }
423
424 pub fn update(
425 &self,

Callers

nothing calls this directly

Calls 3

spawnFunction · 0.85
recvMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected