From 05e9a9b6887f48a1d62cb569ec3b7bc660d9bf7c Mon Sep 17 00:00:00 2001 From: Shautvast Date: Fri, 3 Apr 2026 20:19:04 +0200 Subject: [PATCH] don't overflow the server --- backend/src/routes/tiles.rs | 7 +++++-- .../lib/features/map/presentation/screens/map_screen.dart | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/routes/tiles.rs b/backend/src/routes/tiles.rs index 1528696..7d51839 100644 --- a/backend/src/routes/tiles.rs +++ b/backend/src/routes/tiles.rs @@ -69,8 +69,11 @@ pub async fn get_tile( // Fetch from Martin let (data, etag): (Bytes, Option) = martin.get_tile(&layer, z, x, y).await?; - // Store in cache (fire-and-forget) - cache.set_tile(&cache_key, &data).await; + // Store in cache — spawn so the client doesn't wait for the Redis write. + let cache2 = cache.clone(); + let key2 = cache_key.clone(); + let data2 = data.clone(); + tokio::spawn(async move { cache2.set_tile(&key2, &data2).await }); let mut resp = HttpResponse::Ok(); resp.content_type("application/x-protobuf") diff --git a/mobile/lib/features/map/presentation/screens/map_screen.dart b/mobile/lib/features/map/presentation/screens/map_screen.dart index 1a6137a..8ce1053 100644 --- a/mobile/lib/features/map/presentation/screens/map_screen.dart +++ b/mobile/lib/features/map/presentation/screens/map_screen.dart @@ -75,6 +75,7 @@ class _MapScreenState extends ConsumerState { data: (style) => VectorTileLayer( tileProviders: style.providers, theme: style.theme, + concurrency: 4, ), loading: () => const SizedBox.shrink(), error: (e, _) => const SizedBox.shrink(),