的WebAPI的OutputCache缓存失效 [英] WebAPI OutputCache cache invalidation
问题描述
我有以下缓存属性我控制器的方法:
[CacheOutput(ClientTimeSpan = 14400,ServerTimeSpan = 14400)
我试图清除缓存。但是,运行此行code后:
//清除缓存
cache.RemoveStartsWith(Configuration.CacheOutputConfiguration()MakeBaseCachekey(BeamsController,GET));
我仍然得到被调用,而不在控制器方法304未修改响应。
我使用这个库 https://github.com/filipw/AspNetWebApi-OutputCache
[InvalidateCacheOutput(获取的typeof(BeamsController))]
似乎工作,而不是'人工失效( RemoveStartsWith
)之上。
在实际上,读取属性的源$ C $℃后,看来该文档是错误的,它应该是:
<$p$p><$c$c>cache.RemoveStartsWith(Configuration.CacheOutputConfiguration().MakeBaseCachekey(\"Beams\", 得到));这正如所料,调用该方法的工作原理。
I have the following caching attribute on my controller method:
[CacheOutput(ClientTimeSpan = 14400, ServerTimeSpan = 14400)]
I am attempting to clear the cache. However, after running this line of code:
//clear cache
cache.RemoveStartsWith(Configuration.CacheOutputConfiguration().MakeBaseCachekey("BeamsController", "Get"));
I am still getting a 304 not-modified response without the controller method being invoked.
I am using this library https://github.com/filipw/AspNetWebApi-OutputCache
[InvalidateCacheOutput("Get", typeof(BeamsController))]
seems to work, instead of 'manual invalidation' (RemoveStartsWith
), above.
In fact, after reading the source code of the attribute, it appears that the documentation is wrong and it should be:
cache.RemoveStartsWith(Configuration.CacheOutputConfiguration().MakeBaseCachekey("Beams", "Get"));
which works as expected, calling the method.
这篇关于的WebAPI的OutputCache缓存失效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!