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 1304
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******@nospa mtwcny.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******@nospa mtwcny.rr.com> wrote in message
news:%2******** ********@tk2msf tngp13.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.c om... 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******@nospa mtwcny.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.GetI temFromCache("M yObjKey", 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 GetItemFromCach e(ByVal Key As String, Optional ByVal
myKey As Decimal = 1) As Object
Dim cacheKey As String = Key.ToLower
If IsNothing(HttpR untime.Cache(ca cheKey)) Then
HttpRuntime.Cac he.Insert(cache Key, myObj.NewmyObj( myKey))
End If
Return HttpRuntime.Cac he(cacheKey)
End Function
--
Joe Fallon
"Joe Fallon" <jf******@nospa mtwcny.rr.com> wrote in message
news:#8******** ******@TK2MSFTN GP14.phx.gbl... Thanks! Just what I needed to know. -- Joe Fallon
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message news:b1******** *************** *********@4ax.c om... 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******@nospa mtwcny.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******@nospa mtwcny.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.GetI temFromCache("M yObjKey", 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 GetItemFromCach e(ByVal Key As String, Optional ByVal myKey As Decimal = 1) As Object Dim cacheKey As String = Key.ToLower
If IsNothing(HttpR untime.Cache(ca cheKey)) Then HttpRuntime.Cac he.Insert(cache Key, myObj.NewmyObj( myKey)) End If
Return HttpRuntime.Cac he(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 GetItemFromCach e 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.c om... 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******@nospa mtwcny.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 GetItemFromCach e 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.c om... 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******@nospa mtwcny.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 GetItemFromCach e 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******@nospa mtwcny.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)
{
int* pInts = new int;
for(int i = 0; i < 100; i++)
vec.push_back(pInts);
|
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, AD, BC and CD.
I'm using two nested for loop as below, but it is running very slow
whenever I access any data in the second loop.
|
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 applications.
So my question is about how recommendable is to use a lot of Sessions objects in ASP.Net I want to use in my application 30 of this objects. Im gonna use them for give permissions to the users of the application.
Regards.
|
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
Username must be unique, obviously, and this is enforced at database level,
with a unique index on username field.
I use a BO object to save / load data from database. This BO uses a DataRow
|
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". I'm accessing the cache using
HttpContext.Current.Cache within this assembly. My question is, if I now
start build a standard asp.net application using the same core.dll, will
objects placed in the cache duplicate? Say, core.dll has a NewsItem...
|
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 someone explain what I might be doing wrong
or what to look out for? What's the differece between IIS and VS web server?
The IIS servers seem to have enough memory.
public DataTable GetAll()
{
|
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 store a DataTable in
any other way outside of our servers. In doing so, we leave ourselves
open to large memory requirements. Furthermore, most web pages do not
really support multiple changes per transaction. In other words, when
the user submits...
|
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
representing students that referenced teacher objects.
Then I happened to look at the temporary files created by sessions and
found much redundant data was stored in each file about the teachers
since they were referenced by every student in...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |