i am implementing a nightly in-memory caching patt

PDF · 2 Apr 2026

This guide details a complete implementation of a nightly in‑memory caching pattern using Azure Functions on a dedicated App Service Plan with .NET 8/C#. The pattern loads full crop‑type datasets from an Azure SQL Data Warehouse each night via a timer‑triggered function, stores them in a typed, thread‑safe singleton cache, and serves all subsequent HTTP‑triggered API requests directly from that cache, eliminating per‑request database calls. The document covers cold‑start behavior on dedicated plans and how to mitigate it with a pre‑warm hosted service, the full DI registration for both isolated‑worker and web‑application models, a concrete CropDataCache implementation using ConcurrentDictionary, modernisation of legacy 2020 ADO.NET loading code to async typed records, memory‑sizing heuristics for multi‑crop datasets, the nightly timer function with partial‑failure tolerance and Azure Functions retry policy, error‑handling strategies for SQL timeouts, complete refresh failures, and empty‑cache scenarios, HTTP API design including staleness detection, response codes, and optional CDN caching headers, admin endpoints for forced refresh and cache health status, and an observability checklist (logging, custom Application Insights metrics, health‑check endpoint, alert rules). Recommendations for right‑sizing App Service tiers (B2, P1v3) based on dataset size, and best‑practice configuration snippets (host.json retry, app settings) are also provided.

Topics

Dedicated App Service Plan Cold‑Start Characteristics & Mitigation

Explains that a dedicated plan keeps the worker process alive, eliminating classic cold starts, but process restarts still clear in‑memory state; introduces a pre‑warm IHostedService to repopulate the cache on startup.

More from Gerri

PDF

i_am_evaluating_augment_code_as_the_primary_ai-ass.pdf

6mo ago
PDF

i_am_deciding_whether_to_migrate_a_react_azure_f.pdf

6mo ago
PDF

i_am_managing_quality_assurance_for_an_ai-assisted.pdf

6mo ago
PDF

i_am_building_a_reusable_ai-assisted_development_c.pdf

6mo ago
PDF

i_am_designing_an_ai-assisted_development_workflow.pdf

6mo ago
PDF

i_am_implementing_microsoft_entra_external_id_oau.pdf

6mo ago
PDF

i_am_architecting_a_standalone_react_web_applicati.pdf

6mo ago
PDF

i_am_assessing_whether_to_extract_and_adapt_existi.pdf

6mo ago
PDF

GN_865_Add_Trial_Coord_Company_to_Trial_Search_QUOTE_v2_0___ns_approved_20_05_2025.pdf

6mo ago
PDF

GN_809_Import_Seed_Attributes_QUOTE_v2_0___ns_approved_07_05_2025.pdf

6mo ago
PDF

GN_804_Bulk_Trial_Ratings_Updates_QUOTE_v4_0.pdf

6mo ago
See all content