If I add an instance of an object to the Cache what is returned when I
request the item from the cache?
Is it a clone of the object or is it a reference to the object?
I want to know because I would like to go through the instantiaition process
of a New instance only once and then store the object in the cache.
I need to know if subsequent users of the object will be "stepping on each
other" or not.
So, do I have to speciifcally clone the object or is it the a fresh instance
each time I retrieve it?
(Note: once a user retrieves it and works on it, changes are stored to the
user's session. not back to cache.)
--
Joe Fallon 9 1286
Hi Joe:
You store a reference to an object in the cache, and later, you'll
pull out a reference to the same object. If you make changes to the
object - everyone will see them, not just the code making changes on
one user's behalf.
HTH,
--
Scott http://www.OdeToCode.com/
On Tue, 5 Oct 2004 16:05:32 -0400, "Joe Fallon"
<jf******@nospamtwcny.rr.com> wrote: If I add an instance of an object to the Cache what is returned when I request the item from the cache? Is it a clone of the object or is it a reference to the object?
I want to know because I would like to go through the instantiaition process of a New instance only once and then store the object in the cache. I need to know if subsequent users of the object will be "stepping on each other" or not.
So, do I have to speciifcally clone the object or is it the a fresh instance each time I retrieve it?
(Note: once a user retrieves it and works on it, changes are stored to the user's session. not back to cache.)
It's a reference so you do have to wrap them up in cloning properties...
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... If I add an instance of an object to the Cache what is returned when I request the item from the cache? Is it a clone of the object or is it a reference to the object?
I want to know because I would like to go through the instantiaition
process of a New instance only once and then store the object in the cache. I need to know if subsequent users of the object will be "stepping on each other" or not.
So, do I have to speciifcally clone the object or is it the a fresh
instance each time I retrieve it?
(Note: once a user retrieves it and works on it, changes are stored to the user's session. not back to cache.) -- Joe Fallon
Thanks!
Just what I needed to know.
--
Joe Fallon
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:b1********************************@4ax.com... Hi Joe:
You store a reference to an object in the cache, and later, you'll pull out a reference to the same object. If you make changes to the object - everyone will see them, not just the code making changes on one user's behalf.
HTH,
-- Scott http://www.OdeToCode.com/
On Tue, 5 Oct 2004 16:05:32 -0400, "Joe Fallon" <jf******@nospamtwcny.rr.com> wrote:
If I add an instance of an object to the Cache what is returned when I request the item from the cache? Is it a clone of the object or is it a reference to the object?
I want to know because I would like to go through the instantiaition
processof a New instance only once and then store the object in the cache. I need to know if subsequent users of the object will be "stepping on
eachother" or not.
So, do I have to speciifcally clone the object or is it the a fresh
instanceeach time I retrieve it?
(Note: once a user retrieves it and works on it, changes are stored to
theuser's session. not back to cache.)
OK.
I have it all set up and have not yet implemented cloning.
But so far it seems to not need it. I make changes to the returned object
and store the object in Session and retrieve it and my changes are there.
But another user retrieves the item from cache and there are no changes in
it. If it was a reference then wouldn't I see the changes?
I would prefer to keep it this way if it was safe. Any ideas?
================================================== ====================
Code sample from .aspx code behind:
myObj = CType(Util.GetItemFromCache("MyObjKey", mKey), myObj )
Then in the rest of the page I manipulate myObj. Including storing in
Session for use during postbacks.
================================================== ====================
This is part of the cache function I use to add the object to the cache:
Public Shared Function GetItemFromCache(ByVal Key As String, Optional ByVal
myKey As Decimal = 1) As Object
Dim cacheKey As String = Key.ToLower
If IsNothing(HttpRuntime.Cache(cacheKey)) Then
HttpRuntime.Cache.Insert(cacheKey, myObj.NewmyObj(myKey))
End If
Return HttpRuntime.Cache(cacheKey)
End Function
--
Joe Fallon
"Joe Fallon" <jf******@nospamtwcny.rr.com> wrote in message
news:#8**************@TK2MSFTNGP14.phx.gbl... Thanks! Just what I needed to know. -- Joe Fallon
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message news:b1********************************@4ax.com... Hi Joe:
You store a reference to an object in the cache, and later, you'll pull out a reference to the same object. If you make changes to the object - everyone will see them, not just the code making changes on one user's behalf.
HTH,
-- Scott http://www.OdeToCode.com/
On Tue, 5 Oct 2004 16:05:32 -0400, "Joe Fallon" <jf******@nospamtwcny.rr.com> wrote:
If I add an instance of an object to the Cache what is returned when I request the item from the cache? Is it a clone of the object or is it a reference to the object?
I want to know because I would like to go through the instantiaition processof a New instance only once and then store the object in the cache. I need to know if subsequent users of the object will be "stepping on eachother" or not.
So, do I have to speciifcally clone the object or is it the a fresh instanceeach time I retrieve it?
(Note: once a user retrieves it and works on it, changes are stored to theuser's session. not back to cache.)
Hi Joe:
Yes, you should definitely be getting a reference to the same object
when you ask the cache for "MyObjKey" - regardless of what user
session the code is in.
Is there any chance the code could be overwriting what is in the Cache
somewhere else?
--
Scott http://www.OdeToCode.com/
On Tue, 5 Oct 2004 18:51:48 -0400, "Joe Fallon"
<jf******@nospamtwcny.rr.com> wrote: OK. I have it all set up and have not yet implemented cloning.
But so far it seems to not need it. I make changes to the returned object and store the object in Session and retrieve it and my changes are there. But another user retrieves the item from cache and there are no changes in it. If it was a reference then wouldn't I see the changes?
I would prefer to keep it this way if it was safe. Any ideas?
================================================= ===================== Code sample from .aspx code behind: myObj = CType(Util.GetItemFromCache("MyObjKey", mKey), myObj )
Then in the rest of the page I manipulate myObj. Including storing in Session for use during postbacks.
================================================= =====================
This is part of the cache function I use to add the object to the cache:
Public Shared Function GetItemFromCache(ByVal Key As String, Optional ByVal myKey As Decimal = 1) As Object Dim cacheKey As String = Key.ToLower
If IsNothing(HttpRuntime.Cache(cacheKey)) Then HttpRuntime.Cache.Insert(cacheKey, myObj.NewmyObj(myKey)) End If
Return HttpRuntime.Cache(cacheKey)
End Function
I am just starting to implement this so the answer to your question is no.
The relevant code was posted in my last message.
I always call the function GetItemFromCache from my .aspx page code behind.
As you can see, the function checks the cache for the object and if it
exists, it returns it.
If it does not exist, it creates a new object.
Other tests I conducted (changing default values) show that the object is
always being pulled from cache because the new defaults are not present
until I invalidate the cache.
(BTW - I use DB cache invalidation dependency to do this in ASP.Net 1.1 -
which is really slick. It is supported natively in v 2.0.)
My current theory is that my class has to be serializable to be stored in
Session (or cache) so I wonder if the cache or session methods return the
serialized values each time the object is retireved.
This would validate what I am seeing. The instance in the .aspx form is
filled with the serialized members from the object in cache, so changes to
the object in the code behind never appear in the cache object (unless the
objec is manually added to the cahce which I avoid, since at that time it is
user specific.)
--
Joe Fallon
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:6f********************************@4ax.com... Hi Joe:
Yes, you should definitely be getting a reference to the same object when you ask the cache for "MyObjKey" - regardless of what user session the code is in.
Is there any chance the code could be overwriting what is in the Cache somewhere else?
-- Scott http://www.OdeToCode.com/
By any chance are you using out of processes session state
persistance? (i.e. using the session state service in another process
or using SQL Server?). If so, you are describing the exact behavior.
I was assuming InProc session state, please accept humble apologies if
I caused confusion.
--
Scott http://www.OdeToCode.com/
On Wed, 6 Oct 2004 20:23:42 -0400, "Joe Fallon"
<jf******@nospamtwcny.rr.com> wrote: I am just starting to implement this so the answer to your question is no. The relevant code was posted in my last message.
I always call the function GetItemFromCache from my .aspx page code behind.
As you can see, the function checks the cache for the object and if it exists, it returns it. If it does not exist, it creates a new object.
Other tests I conducted (changing default values) show that the object is always being pulled from cache because the new defaults are not present until I invalidate the cache. (BTW - I use DB cache invalidation dependency to do this in ASP.Net 1.1 - which is really slick. It is supported natively in v 2.0.)
My current theory is that my class has to be serializable to be stored in Session (or cache) so I wonder if the cache or session methods return the serialized values each time the object is retireved. This would validate what I am seeing. The instance in the .aspx form is filled with the serialized members from the object in cache, so changes to the object in the code behind never appear in the cache object (unless the objec is manually added to the cahce which I avoid, since at that time it is user specific.)
Yes. I am using Out of Proc session state.
Are you saying that under that scenario, the application cache is *also*
stored out of process?
I was not aware of that.
That would explain the behavior I am seeing.
--
Joe Fallon
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:56********************************@4ax.com... By any chance are you using out of processes session state persistance? (i.e. using the session state service in another process or using SQL Server?). If so, you are describing the exact behavior.
I was assuming InProc session state, please accept humble apologies if I caused confusion.
-- Scott http://www.OdeToCode.com/
On Wed, 6 Oct 2004 20:23:42 -0400, "Joe Fallon" <jf******@nospamtwcny.rr.com> wrote:
I am just starting to implement this so the answer to your question is no. The relevant code was posted in my last message.
I always call the function GetItemFromCache from my .aspx page code behind.
As you can see, the function checks the cache for the object and if it exists, it returns it. If it does not exist, it creates a new object.
Other tests I conducted (changing default values) show that the object is always being pulled from cache because the new defaults are not present until I invalidate the cache. (BTW - I use DB cache invalidation dependency to do this in ASP.Net 1.1 - which is really slick. It is supported natively in v 2.0.)
My current theory is that my class has to be serializable to be stored in Session (or cache) so I wonder if the cache or session methods return the serialized values each time the object is retireved. This would validate what I am seeing. The instance in the .aspx form is filled with the serialized members from the object in cache, so changes to the object in the code behind never appear in the cache object (unless the objec is manually added to the cahce which I avoid, since at that time it is user specific.)
Application cache is definitely in process.
--
Scott http://www.OdeToCode.com/
On Wed, 6 Oct 2004 22:39:55 -0400, "Joe Fallon"
<jf******@nospamtwcny.rr.com> wrote: Yes. I am using Out of Proc session state.
Are you saying that under that scenario, the application cache is *also* stored out of process? I was not aware of that.
That would explain the behavior I am seeing. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jeff Williams |
last post by:
Ok, everyone loves to talk about dynamic arrays and ptr's etc, they provide
endless conversation :) so here goes:
Will this leak memory (my intuition says yes):
void foo(vector<int*>& vec)
{...
|
by: pertheli |
last post by:
Hello,
I have a large array of pointer to some object. I have to run test
such that every possible pair in the array is tested.
eg. if A,B,C,D are items of the array,
possible pairs are AB, AC,...
|
by: Miguel |
last post by:
Hi all friends:
It's said that Sessions objects in ASP 3.0 with IIS 5.0 occupy certain memory of the machine which take to take care about use a lot of Sessions objects in the ASPs pages of the...
|
by: NWx |
last post by:
Hi,
I discovered a strange (?!?!) issue related objects saved to cache.
Let's explain my situation.
I have a webform for user registration. Users enter username, password and
other info...
|
by: Narshe |
last post by:
I've been struggling with this for a while.
I have a business entity Employee that has a Company entity attached
to it.
Ex:
public class Compay{ // blah }
public class Employee
|
by: matthias s |
last post by:
Hi There,
I'm currently building a webservice using a class library which encapsulates
all business logic and a cache mechanism as well to hold recently used
objects. Lets call this "core.dll"....
|
by: J055 |
last post by:
Hi
The following code works on my develeopment machine using the VS web server.
When I run the application on 2 other Windows 2003/IIS 6 servers no caching
seems to take place at all. Can...
|
by: jehugaleahsa |
last post by:
Hello:
What is the point of using a DataTable in ASP .NET? We are unsure how
you can use them without 1) rebuilding them every postback, or 2)
taking up precious memory. We are not sure how to...
|
by: DigitalDave |
last post by:
A project I did awhile back stored php5 objects in elements of the
$_SESSION array between pages that were navigated on the site. There
were object classes representing teachers, and object classes...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |