如何远程清除缓存? [英] How do I clear the cache remotely ?

查看:115
本文介绍了如何远程清除缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:我有一个存储在内存缓存中的对象(来自DB的结果集)(cache.Add(key,object))。此缓存具有绝对过期作为缓存策略。有时我需要在到期之前清除缓存中的对象(cache.Remove(key))。我的应用程序在IIS上运行,永远不会停止。



问题:所以我的问题是如何使用单独的应用程序实现这一目标?或者是否还有其他方法可以在缓存达到绝对到期之前清除缓存?

Scenario : I have an object (result set from DB) stored in memory cache (cache.Add(key, object)). This cache is having absolute expiration as cache policy. Some times I need to clear the object in cache (cache.Remove(key)) before the expiration. My application is running on IIS which should never be stopped.

Question: So my question is how can I achieve this using a separate application ? Or is there any other way to clear cache before it reaches the absolute expiration ?

推荐答案

当您使用ASP.NET时,您可能需要创建一个按钮和/或者将执行此操作的页面,这将触发ASP.NET服务器上的代码以调用cache.Remove(key)。



假设清除缓存是某种东西你不希望普通用户这样做,最好的方法是将页面/按钮放在他们无法访问的地方,或隐藏普通用户。



如果你使用webforms,也许在你的页面上创建一个按钮,当点击它时执行cache.Remove调用,并且只有在你登录时才将可见性设置为true。



如果使用MVC,可能是一个调用控制器上调用cache.Remove的方法的链接
As you're using ASP.NET you probably need to create a button and/or page that will do this, and this will trigger the code on your ASP.NET server to call cache.Remove(key).

Assuming clearing the cache is something you don't want normal users to do, the best approach is to put the page/button somewhere they cannot access it, or hide from normal users.

If you're using webforms, perhaps create a button on your page that when clicked performs the cache.Remove call, and set visibility to true only if it's you logged in.

If using MVC, perhaps a link that calls a method on the controller which calls cache.Remove


这篇关于如何远程清除缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆