Re: Cache problem
- From: "Joe Fallon" <jfallon1@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 1 Jun 2005 14:09:01 -0400
I found this using Google:
========================================================
This is the expected behaviour. What you really get from of the cache is a
reference to the object in cache. Changes to this object are seen by
everyone that has a reference to this object.
You could solve this by wrapping the Cache access in a method that gets the
excel object from the cache and then clones it, before giving a reference to
the clone to you. But this might not be enough, since this is only a shallow
copy (objects referenced in the original are not copied, just their
references). Depends on how the excel object is implemented.
========================================================
I believe the shallow copy is my problem as I change one of the internal
objects using a reference.
--
Joe Fallon
"Joe Fallon" <jfallon1@xxxxxxxxxxxxxxxxxx> wrote in message
news:OAufzJtZFHA.2984@xxxxxxxxxxxxxxxxxxxxxxx
> I have a class which is stored in the cache.
> When I retrieve it from cache I return a clone of the class so that I do
not
> keep a reference to the cached item. (That is the theory anyway.)
>
> When I modify the cloned object and then navigate to another page, the
data
> in the cache is modified with my changes anyway!
>
> So when I go to another page and expect a "clean" copy of my class to be
> retrieved from the cache, it is "dirty" with the changes made on a
different
> page.
>
> Can someone please explain what is happening here?
> I thought that returning a clone would break the reference to the cached
> object.
>
> I would hate to have to abandon this technique, but if it doesn't work....
> --
> Joe Fallon
>
>
>
.
- References:
- Cache problem
- From: Joe Fallon
- Cache problem
- Prev by Date: Re: Same aspx page/different folders
- Next by Date: Re: Viewstate of variables.
- Previous by thread: Cache problem
- Next by thread: Same aspx page/different folders
- Index(es):
Relevant Pages
|