How to refresh the KVM cache forcefully

In the KVM configuration, I have setup the cache expiry time as 24 hrs. But, when I changed my KVM value in the middle, the change got reflected in the flow only after 24 hrs (which is not developer friendly)

Is it possible to explicitly invalidate the KVM, and force a cache update?

1 10 4,367
10 REPLIES 10

any suggestions on the above query? appreciate it if a solution is provided as soon as possible

@maivizhi

How vulnerable is it? If you are changing KVM values once in a while (during development only), then you may set the expiry time to lesser value during the change and have it readily affected through the development process.

Thanks @Nisha Mallesh

Please find my detailed analysis on KVM 🙂

  1. Updated KVM entry in UI
  2. Deleted the KVM entry from UI
  3. Updated the expiry time in KVM policy (24 hrs to 10 secs)

In all three case i could see the below observation

  • When i test it through Management api.I am able to see the updated value(Hope its pulling the data from Datastore)
  • But the same is not reflecting back in KVM policy as the value is being pulled from Cache(in-memory)

When i tried updating the expiry time in KVM to 10 secs and when i tried my request i could still see that the KVM is still pointing to the old value(Hope the cached value will retain the old value forl 24 hrs though the expiry time is updated)

Badly waiting for a solution to flush the cached value and update with new value in KVM cache

Wondering what if we make the KVM expiry time as never expire !

Hey @maivizhi,

I have used the same approach and it works as required. Can you try changing the name of KVM, also ensure the KVM policy is rightly configured.

Not applicable

Hi @maivizhi

Documentation says :Use -1 only when a value will never change, because Edge will never refresh it. If you've already set -1 and you want to refresh based on a new expiration interval, create a new KeyValueMap and reference it in the policy (with the mapIdentifier).

Read More about KVM

I did not find a way to clear the KVM cache. What you can do is create a new KVM and refrer to this KVM in mapIdentifier (as suggested in documentation).

Two things -

If you use 0 or anything less than 0, I believe the behavior now is to use the default TTL, which is 300 seconds. (The doc has been updated).

You can clear the KVM cache as a side effect by writing any value (Put operation) with an ExpiryTImeInSecs of 1.

Eg

<KeyValueMapOperations name='KVM-Put-Clear' mapIdentifier='nameOfMap'>
  <Scope>organization</Scope>
  <Put override='true'>
    <Key>
      <Parameter>p1</Parameter>
    </Key>
    <Value>Something</Value>
  </Put>
  <ExpiryTimeInSecs>1</ExpiryTimeInSecs>
</KeyValueMapOperations>

This has the effect of writing the KVM and loading the written value into the cache with a TTL of 1 second. After 1 second the cache entry will disappear; though the value you've written to the KVM will remain in persistent store.

This is the nice workaround @Dino-at-Google, Thanks for sharing the option.

I almost did this only to realize that the KVM name/ identifier promoted by the one who serviced it is wrong. I didn't realized it as the one that is being shown in my browser turns out to be he old cache of the KVM name, and not the latest KVM name. And when I open that old cache of the KVM, it would show the correct updated keys, but it wont just show the updated KVM name and instead shown me the old KVM name. So I have my browser reset then to be able to see the latest KVM name in the Apigee Edge UI, and finally be able to realize the service guy did something wrong in updating the KVM and not us or our APIs, haha.

anshul_
Participant IV

Hi @maivizhi,

If you will update the KVM entry using the policy instead of management UI or management API then it will refreshes the cache for you. So a temporary solution that I would suggest is - create an utility API which updates your KVM using the KeyValueMap policy.

rashid4844
Participant II

Simple change the ExpiryTime in read KVM policy