Azure API Management - Internal cache

Ravi Kiran 1 Reputation point
2022-03-02T18:40:57.773+00:00

Hi, I am in a process of exploring Azure API Management for our project and tried looking for below questions over the internet but couldn't get to a conclusive information. I am using internal cache and API Management is not geo replicated

Is there a way I can find out cache key for my API, which I can invalidate at any point of time if needed before specified elapse time.
or
Is there a way I can invalidate all the cache at once in the instance
or
Can I specify a custom cache key to the API where I will have handle to invalidate when needed

Thank you in Advance for helping me out!!!

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,184 questions
{count} votes

2 answers

Sort by: Most helpful
  1. MayankBargali-MSFT 70,546 Reputation points
    2022-03-03T12:52:57.767+00:00

    @Ravi Kiran Thanks for reaching out. I believe you might be already looked into the Azure APIM cache policy document but sharing the same for the community members.
    You can leverage the APIM management REST API to perform supported operations on APIM. You can refer to the cache REST document for the operation supported for APIM cache.

    Is there a way I can find out cache key for my API, which I can invalidate at any point of time if needed before specified elapse time.
    You can leverage the List by Service API to list all the caches created for your APIM instance and to invalid/delete the cached you can call the Delete operation

    Is there a way I can invalidate all the cache at once in the instance
    Yes, you need to first call the List by Service API and loop in through all the return cache array, and call the Delete Operation on the individual cache.

    Can I specify a custom cache key to the API where I will have handle to invalidate when needed
    Whenever you create the cache within the policy then you need to assign the cache key. If your requirement is that based on input body/parameter while calling the APIM API you want to delete/invalid the cache then yes you need to write your custom logic in your policy to handle this. You can leverage the C# expression in your policy to handle it. Now to invalid the cache you need to leverage the Send request policy to create the HTTP request to invalid/delete the cache as per your business requirement.

    To get familiar with the Azure REST API you can refer to this document.

    1 person found this answer helpful.

  2. Jelle Botterman 5 Reputation points
    2024-06-17T13:46:03.75+00:00

    The REST documentation only works for external caches, this is not clear from the documentation.

    We started using an Azure Redis Cache to enable more capabilities like flushing all keys at once.

    Using a VS Code extension you can then view, edit, delete keys/values as well.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.