有没有办法从服务器场清除缓存? [英] Is there any way to clear cache from server farm?

查看:160
本文介绍了有没有办法从服务器场清除缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个应用程序中实现的OutputCache,它工作正常,但因为我指定的位置服务器,应用服务器群(2台服务器)中运行,当我清除缓存,它只是从一台服务器在清除一次。我曾经想过指定服务器位置(硬code),使高速缓存将被存储在一个地方,可以当我必须很容易清除。
那么,有没有什么办法硬code服务器名称中的OutputCache位置属性?或者从webconfig文件?

I have implemented OutputCache in an application and it works fine, but since I have specified the location as server, and the applications runs in server farm (2 servers) , when I clear the cache, it clears only from one server at one time. I have thought about specifying a server location (hardcode), so that the cache will be stored at one place and can be easily cleared when I have to. So, is there any way to hardcode server name for the location attribute in OutputCache? Or from webconfig file?

在webconfig

Declaration in webconfig

<system.web>
<caching>
  <outputCacheSettings>
    <outputCacheProfiles>
      <add name="Cache10Minutes"
           duration="300"
           location="Server"
           varyByParam="none"/>
    </outputCacheProfiles>
  </outputCacheSettings>
</caching>

在相关的页面定义(页头)

Definition in related page (page header)

<%@ OutputCache CacheProfile="Cache10Minutes" Duration="300" Location="Server" VaryByParam="none"%>

要清除按钮点击缓存

HttpRuntime.UnloadAppDomain()

或者有关从客户端上的更新制作从数据库触发器什么。可以从两个服务器这个明确的缓存?纠正我,如果我的想法是错误的,或不够清晰,我很困惑。请指点。

Or what about creating a trigger from database on update from client. Can this clear cache from both the servers? Correct me if my idea is wrong or not clear enough, I'm confused. Please advice.

推荐答案

据我所知输出缓存只占服务器。您可以实现自己的但 OutputCacheProvider 和实现自己的缓存机制:<一href=\"https://msdn.microsoft.com/en-us/library/system.web.caching.outputcacheprovider(v=vs.110).aspx\"相对=nofollow称号=OutputCacheProvider类,MSDN> OutputCacheProvider类,MSDN

As far as I know output cache is per server only. You can implement your own OutputCacheProvider however and implement your own caching mechanism: OutputCacheProvider Class, MSDN

OutputCacheProvider对Redis的

也许使用分布式高速缓存的AppFabric:如何于:配置ASP.NET 的AppFabric的输出缓存提供。要知道,虽然微软即将结束对Windows Server明年<一对AppFabric的支持href=\"http://blogs.msdn.com/b/appfabric/archive/2015/04/02/windows-server-appfabric-1-1-ends-support-4-2-2016.aspx\"相对=nofollow>微软的AppFabric 1.1的Windows服务器终止支持2016年4月2日

Or maybe use distributed cache with AppFabric: How to: Configure the AppFabric Output Cache Provider for ASP.NET . Be aware though that Microsoft is ending support for AppFabric for Windows Server next year Microsoft AppFabric 1.1 for Windows Server Ends Support 4/2/2016

这篇关于有没有办法从服务器场清除缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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