Invalidating a cache
All we do here is look for any Arguments which implement IAm Cacheable and then use a combination of the Type name and the IAm Cacheable. We also make sure the method is called first by calling Invocation. Finally we need to wire up this new Interceptor in the Bootstrapper.
The region applied to cache them uses a custom key generator which tracks each cache key generated, pulling out the integer “id” and replacing with a template.
This article will feature the use of the triggered i Call handler to allow a user to submit a http request to invalidate the cache served up for an application managed by the Application Acceleration Manager.
Before we get to the solution, I'd like to address the use case for invalidating cache.
In this post I hope to explain how with a bit of convention over configuration how you can invalidate your cache when an object changes.
In the last post I was using the Method name combined with the arguments to build the cache key.
If you implement a Proxy Backend to encode/decode data, that transformation will happen on the pre-pickled data- dogpile does not store the data ‘raw’ and will still pass a pickled payload to the backend.
I'll leave it as an exercise for the reader to make that step more dynamic.The main change here is in the Build Cache Key From method.What I’m doing here is looking for the value of the Argument named “id” and using this combined with the Type name to build the key which would end up like “Product-1”.Since dogpile is managing cached data, you may be concerned with the size of your payloads.A possible method of helping minimize payloads is to use a Proxy Backend to recode the data on-the-fly or otherwise transform data as it enters or leaves persistent storage.