ASP.Net, caches, scope of statics

ASP.Net, caches, scope of statics

am 16.04.2008 23:58:01 von mmodrall

Hi...

At least by the group title, this seems like a question for
dotnet.framework.aspnet.caching but that group seems pretty slow.

I'm trying to sort things out with a co-worker. We've got some classes that
implement some in-memory caches with static Hashtable members. My
understanding is that a static Hashtable may be shared between threads in
the worker process but that it won't span multiple worker processes.

I'm not sure about the System.Web.Caching.Cache class. You can't
instantiate one of your own, so I'm not sure if there's something buried down
in the framework to make this work across processes in a garden.

Also not sure if you can achieve better sharing by putting a C# class in the
Application scope (sorry if that's nonsensical; I haven't actually put
objects in application scope since classic asp).

Thanks
Mark

RE: ASP.Net, caches, scope of statics

am 17.04.2008 05:54:13 von stcheng

Hi Mark,

Regarding on the ASP.NET Cache question you mentioned, here are some of my
understanding:

** ASP.NET Cache is per AppDomain based. Since each ASP.NET application is
scoped at AppDomain level(just like normal .net application), different
ASP.NET application instances(such as webfarm instances) can not share
Cache data.

** Sure, you can use some custom Class and Static member properties to
cache data instead of built-in Cache, the scope is the same(within the same
appdomain). However, the advantage of ASP.NET Cache is that it provide
multiple Cache Dependencies that can help you add auto-expire/invalidate
support. For example, you can use time based or data based cache dependency
so as to make a cache item be invalidated after a certain timespan (or a
certain database table is changed).

** If you have requirement to share data among webfarm server instances. I
think using database is still the preferred approach.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/de fault.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
>From: =?Utf-8?B?TWFyaw==?=
>Subject: ASP.Net, caches, scope of statics
>Date: Wed, 16 Apr 2008 14:58:01 -0700

>Hi...
>
>At least by the group title, this seems like a question for
>dotnet.framework.aspnet.caching but that group seems pretty slow.
>
>I'm trying to sort things out with a co-worker. We've got some classes
that
>implement some in-memory caches with static Hashtable members. My
>understanding is that a static Hashtable may be shared between threads in
>the worker process but that it won't span multiple worker processes.
>
>I'm not sure about the System.Web.Caching.Cache class. You can't
>instantiate one of your own, so I'm not sure if there's something buried
down
>in the framework to make this work across processes in a garden.
>
>Also not sure if you can achieve better sharing by putting a C# class in
the
>Application scope (sorry if that's nonsensical; I haven't actually put
>objects in application scope since classic asp).
>
>Thanks
>Mark
>
>

Re: ASP.Net, caches, scope of statics

am 21.04.2008 06:32:45 von Xiuming

If you'd like to share data among different processes(in this
situation, web farm contains a lot of different processes), it's
better redesign your application structure.
You can use a remoting server here as a centralized caching service
serving different web applications.



On Apr 17, 5:58=A0am, Mark wrote:
> Hi...
>
> At least by the group title, this seems like a question for
> dotnet.framework.aspnet.caching but that group seems pretty slow.
>
> I'm trying to sort things out with a co-worker. =A0We've got some classes =
that
> implement some in-memory caches with static Hashtable members. =A0My
> understanding is that a static Hashtable may be shared between threads =A0=
in
> the worker process but that it won't span multiple worker processes.
>
> I'm not sure about the System.Web.Caching.Cache class. =A0You can't
> instantiate one of your own, so I'm not sure if there's something buried d=
own
> in the framework to make this work across processes in a garden.
>
> Also not sure if you can achieve better sharing by putting a C# class in t=
he
> Application scope (sorry if that's nonsensical; I haven't actually put
> objects in application scope since classic asp).
>
> Thanks
> Mark

RE: ASP.Net, caches, scope of statics

am 23.04.2008 12:33:18 von stcheng

Hi Mark,

How are you doing, do you have any further questions on this?

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/de fault.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>Content-Type: text/plain
>Content-Transfer-Encoding: 7bit
>From: stcheng@online.microsoft.com (Steven Cheng [MSFT])
>Organization: Microsoft
>Date: Thu, 17 Apr 2008 03:54:13 GMT
>Subject: RE: ASP.Net, caches, scope of statics

>
>Hi Mark,
>
>Regarding on the ASP.NET Cache question you mentioned, here are some of my
>understanding:
>
>** ASP.NET Cache is per AppDomain based. Since each ASP.NET application is
>scoped at AppDomain level(just like normal .net application), different
>ASP.NET application instances(such as webfarm instances) can not share
>Cache data.
>
>** Sure, you can use some custom Class and Static member properties to
>cache data instead of built-in Cache, the scope is the same(within the
same
>appdomain). However, the advantage of ASP.NET Cache is that it provide
>multiple Cache Dependencies that can help you add auto-expire/invalidate
>support. For example, you can use time based or data based cache
dependency
>so as to make a cache item be invalidated after a certain timespan (or a
>certain database table is changed).
>
>** If you have requirement to share data among webfarm server instances. I
>think using database is still the preferred approach.
>
>Sincerely,
>
>Steven Cheng
>
>Microsoft MSDN Online Support Lead
>
>
>Delighting our customers is our #1 priority. We welcome your comments and
>suggestions about how we can improve the support we provide to you. Please
>feel free to let my manager know what you think of the level of service
>provided. You can send feedback directly to my manager at:
>msdnmg@microsoft.com.
>
>==================================================
>Get notification to my posts through email? Please refer to
>http://msdn.microsoft.com/subscriptions/managednewsgroups/d efault.aspx#noti
f
>ications.
>
>==================================================
>This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>--------------------
>>From: =?Utf-8?B?TWFyaw==?=
>>Subject: ASP.Net, caches, scope of statics
>>Date: Wed, 16 Apr 2008 14:58:01 -0700
>
>>Hi...
>>
>>At least by the group title, this seems like a question for
>>dotnet.framework.aspnet.caching but that group seems pretty slow.
>>
>>I'm trying to sort things out with a co-worker. We've got some classes
>that
>>implement some in-memory caches with static Hashtable members. My
>>understanding is that a static Hashtable may be shared between threads
in
>>the worker process but that it won't span multiple worker processes.
>>
>>I'm not sure about the System.Web.Caching.Cache class. You can't
>>instantiate one of your own, so I'm not sure if there's something buried
>down
>>in the framework to make this work across processes in a garden.
>>
>>Also not sure if you can achieve better sharing by putting a C# class in
>the
>>Application scope (sorry if that's nonsensical; I haven't actually put
>>objects in application scope since classic asp).
>>
>>Thanks
>>Mark
>>
>>
>
>