caching - CacheOutput Attribute Ignoring Azure-hosted Redis Cache -
I have yet to output caching of my ASP.NET Web API controllers to an Azure hosted radis cache.
I have written a custom class that implements Strawal Web and calls equivalent stackexchange methods. It is registered as proven in cache output in global .asax.cs.
Here is an example usage:
Public class MyApiController: ApiController {Private const int FIFTEEN_MINUTES_IN_SECONDS = 900; [CacheOutput (ClientTimespain = FIFTEEN_MINUTES_IN_SECONDS, ServerTimespace = FIFTEEN_MINUTES_IN_SECONDS)] async Public Tasks & lt; Data & gt; GetAsync (integer param1, string paragraph 2) {return to GetExpensiveData (); } [Serialable] Public class data {// member left for comments}}
When AP Andpo is called on, then I can see that the framework is correctly all my essentials Calling methods IApiOutputCache class is included, set up and receive However, even when a cached copy is found and returns, the GetExpensiveData () method always runs and returns the 'Fresh' data .
No errors are dropped. Cache is working
P> problem solving I was wrongly calling my IApiOutputCache class in Redis
before ...
Public class AzureRedisApiOutputCache:. IApiOutputCache {Get Public Objects (String Key) {return to AzureRedisCache.Instance. .GetDatabase () StringGet (key); }}
after ...
Public class AzureRedisApiOutputCache: IApiOutputCache {Get public object (string key) {// extension method also That's the call Deserialization ... back to AzureRedisCache.Instance.GetDatabase (). Go (key); }} Public Static Class RedisDatabaseExtensions {Get public static object (this IDbase cache, string key) {Dealsize & lt; Object & gt; (Cache.StringGet (key)); }}
It was confusing for some time because the CacheOutput Framework never reported any errors. It only failed silently and came back to the controlling system.
Comments
Post a Comment