473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Scope of Cache

There are a few different ways to use cache in Asp.net.

What I want to know is what is the scope of these cache methods. what I mean
by scope is are are they cached for the one user or not.

if I use System.Web.HttpRuntime.Cache am I caching for all users who come to
the site?
Can I set a expiry for System.Web.HttpRuntime.Cache?
Should I use Application("variable") or has this been superseded?

--
Dim Alan as ThatsIT.net.au.Staffmember
Alan = New ThatsIT.net.au.Staffmember
Alan.signature = "Thank You"
Dim you as NewsgroupReader
you = New NewsgroupReader
Response.Write Alan.signature.toString()
Response.Write you.getName()
__________________________________________

Jun 30 '07 #1
4 8150
Hi
if I use System.Web.HttpRuntime.Cache am I caching for all users who come
to the site?
Yes, exactly. Cache is global.
Can I set a expiry for System.Web.HttpRuntime.Cache?
Yes, within Insert method when adding items to Cache
Should I use Application("variable") or has this been superseded?
Cache supersedes Application since it has callback functionality (in case of
expiration), cache item priority for memory handling etc. Cache is much more
versatile than Application.
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
Jun 30 '07 #2
Cache is available for the duration of the app domain life time, that is, for
the life time of the web application. Also, it is not per-user basis.

"ThatsIT.net.au" wrote:
There are a few different ways to use cache in Asp.net.

What I want to know is what is the scope of these cache methods. what I mean
by scope is are are they cached for the one user or not.

if I use System.Web.HttpRuntime.Cache am I caching for all users who come to
the site?
Can I set a expiry for System.Web.HttpRuntime.Cache?
Should I use Application("variable") or has this been superseded?

--
Dim Alan as ThatsIT.net.au.Staffmember
Alan = New ThatsIT.net.au.Staffmember
Alan.signature = "Thank You"
Dim you as NewsgroupReader
you = New NewsgroupReader
Response.Write Alan.signature.toString()
Response.Write you.getName()
__________________________________________

Jun 30 '07 #3
Hi,
>What is the scope of these cache methods.
Scope is an application (AppDomain), so you can use it for all users of the
application (site).
if I use System.Web.HttpRuntime.Cache am I caching for all users who come
to the site?
For this only site - yes (the current application).
Can I set a expiry for System.Web.HttpRuntime.Cache?
Even priority:
http://msdn2.microsoft.com/en-us/lib...cache.add.aspx
Should I use Application("variable") or has this been superseded?
Cache has self-clearance and dependencies ability, Application doesn't have
it (more persisted). Select based upon these features.

Regards, Alex
[TechBlog] http://devkids.blogspot.com
There are a few different ways to use cache in Asp.net.

What I want to know is what is the scope of these cache methods. what
I mean by scope is are are they cached for the one user or not.

if I use System.Web.HttpRuntime.Cache am I caching for all users who
come to
the site?
Can I set a expiry for System.Web.HttpRuntime.Cache?
Should I use Application("variable") or has this been superseded?

Jun 30 '07 #4
"ThatsIT.net.au" <me@thatsitwrote in message
news:96**********************************@microsof t.com...
There are a few different ways to use cache in Asp.net.
Indeed there are!
What I want to know is what is the scope of these cache methods. what I
mean by scope is are are they cached for the one user or not.
Cache is a global object - like the application object, so its a shared
object. To use it for indivusdals you would need to be caching objects like
you would if you placed them in session - not a good idea really!
if I use System.Web.HttpRuntime.Cache am I caching for all users who come
to the site?
Yes - while that application is in memory
Can I set a expiry for System.Web.HttpRuntime.Cache?
Yes- refer to the docs at msdn
Should I use Application("variable") or has this been superseded?
You can - cache is more flexible, but app is still available and still very
useful really! Your choice!

Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
Jul 1 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Chris | last post by:
Hi, I am writing a webpage in C#. Visual Studio .NET. the following code does not provide me with intellisence on the context, session, and page.cache. When I put the large if...then...
10
by: Brian | last post by:
If i declare a module level oledbconnection with each request for the page, the variable remains in scope? I get open.executing error message on subsequent calls for the page. I assumed ASP.Net...
3
by: Arthur Dzhelali | last post by:
Is there any way to cache dataset on one page and it will be accessible for one user? if you declare dataset shared it will stay on the server and page will be able reference to it on reload,...
5
by: sklett | last post by:
Hi- I am having a hard time decided where I should be implementing my Cache code. I store most of the DataSet's that I need in the Cache. I was doing it in the bind method of my pages, but...
7
by: John A Grandy | last post by:
For a singleton class utilizes by ASP.NET 2.0 page processing: When initial instantiation is performed during the initial call to the retrieve instance method (let's call the method...
5
by: Stan SR | last post by:
Hi, Some newbie questions.. :-) First, what is the namespace to use for the Cache class ? When I use this bit of code I get an error if (Cache==null) Cache.Insert("myUserList",userlist);...
3
by: Max2006 | last post by:
Hi, Is Page.Cache global and shared between all session? What would be the best way to cache an object and share it btween all sessions? I like to avoid Application object because it doesn't...
3
by: =?Utf-8?B?T2xlZw==?= | last post by:
Using ASP.NET 2.0 I always thought that cache has a global scope in the web application. Is it possible to save an object to the page cache so it's not in the application scope? And if I set...
3
by: =?Utf-8?B?TWFyaw==?= | last post by:
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.