问题描述
我有两个应用程序 - 一个是一个asp.net网站,另一种是窗口服务
i have two applications - one is an asp.net website and the other is a windows service.
这两个应用程序所引用我的业务层(库项目),其本身会引用本身使用企业库数据应用模块来接收数据形成一个SQL Server 2005数据库我的数据访问层(库项目)。
both applications are referencing my business layer (library project), which itself is referencing my data access layer (library project) that itself uses the enterprise library data application block to receive the data form a sql server 2005 database.
目前我使用的System.Web.Caching.Cache对象在我的BL缓存我的一些对象:
currently i use the System.Web.Caching.Cache object in my BL to cache some of my objects:
public static System.Web.Caching.Cache Cache
{
get
{
if(cache == null)
{
if (System.Web.HttpContext.Current != null)
{
//asp.net
cache = System.Web.HttpContext.Current.Cache;
}
else
{
//windows service
cache = System.Web.HttpRuntime.Cache;
}
}
return cache;
}
}
由于这两个应用程序都在自己的运行 - 它们都使用自己独立的Cache对象 - 这实际上是这个问题:
as both applications are running on their own - they both are using a separate Cache object on their own - and this is the problem actually:
如果我更改了asp.net网站对象,并将其保存到数据库。对象向此高速缓存关键是从缓存中删除 - 在asp.net应用程序的缓存!这很好。
if i change a object in the asp.net website and save it to the DB. the object to this cache key is removed from the cache - the asp.net application's cache! that's fine.
但Windows服务的缓存变得陈旧!
but the windows service's Cache becomes stale!
(反之亦然)
是有可能,这两个应用程序都使用相同的缓存?这两个应用程序的高速缓存?
is it possible that both applications are using the same Cache? One Cache for both applications?
唯一的选择,我有我想的是,我将不得不使用的SqlDependency与
the only option i have i think about is that i will have to use SqlDependency with
有没有别的办法?
编辑:
我刚刚发现。我会试试看。
如因为速度将在发布候选状态,直到2009年中期。
i just found http://www.codeplex.com/SharedCache. i will give it a try.as because velocity will be in release candidate status until mid 2009.
推荐答案
您应该采取微软的新的免费的分布式缓存显著看速度。
You should take a significant look at Microsoft's new free distributed cache "Velocity."
下面是一个播客我关于这个问题所做的:
http://www.hanselman.com/blog/HanselminutesPodcast116DistributedCachingWithMicrosoftsVelocity.aspx
Here's a podcast I did on the subject:http://www.hanselman.com/blog/HanselminutesPodcast116DistributedCachingWithMicrosoftsVelocity.aspx
下面是MSDN上的细节:
Here's details on MSDN: http://msdn.microsoft.com/en-us/data/cc655792.aspx
下面是下载和样品:
这篇关于各种应用之一缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!