Search code examples
azurecachingazure-redis-cache

Can the server's in-memory cache be used in Azure?


I need my Web API to have caching to store some data. I have been researching caching on Azure and I can see that Microsoft recommends to use Redis cache.

Can I use the normal server's in-memory cache to store simple data which will only be accessed by the Web API or is Redis my only option. Are there any limitations of server memory on Azure?


Solution

  • Of course, you can. Azure Redis cache is not the only option. You can consider to use Microsoft.Extensions.Caching.Memory like MemoryCache to store your simple data, and make sure the size of your data is less than the available tails memory size on Azure App Service which be restricted by the memory limit of Azure App Services for different tiers, as the figure below from App Service limits.

    enter image description here enter image description here

    Meanwhile, even you can consider to implement your Web API by using Azure Functions with HTTP trigger which support more memory, please refer to Functions limits.

    enter image description here enter image description here

    Hope it helps.