Hi,
I'm using the cache block of the enterprise lib Jan. 2006.
There is somethings strange going on.
I add a varable to the cache, let's say the string myData.
string myData = "1111111";
primitivesCache.Add("Key1", myData, CacheItemPriority.Normal, null, new
SlidingTime(TimeSpan.FromMinutes(15)));
When I do after this line this:
myData = "*****";
And I get my data out of the cache manager then myData has the value of
*********. I also tried to load it inside an other variable. Again the
value is the same.
How is it posible that the data in the cache is changed? Or not added
liked I did?
Thanks!
Arjen 5 2098
Arjen wrote:
Hi,
I'm using the cache block of the enterprise lib Jan. 2006.
There is somethings strange going on.
I add a varable to the cache, let's say the string myData.
string myData = "1111111";
primitivesCache.Add("Key1", myData, CacheItemPriority.Normal, null, new
SlidingTime(TimeSpan.FromMinutes(15)));
When I do after this line this:
myData = "*****";
And I get my data out of the cache manager then myData has the value of
*********. I also tried to load it inside an other variable. Again the
value is the same.
How is it posible that the data in the cache is changed? Or not added
liked I did?
Please post a short but complete program that demonstrates your
problem. See Jon Skeet's page for a description of what constitutes a
"short but complete program": http://www.yoda.arachsys.com/csharp/complete.html
Well, I found the problem... still strange...
I add an item to the cache.
After that I change the item, and also the item in the cache is changed
(why?).
Now I have made a copy of the variable after I add it to the cache.
This works fine.
Thanks.
Arjen
Bruce Wood wrote:
Arjen wrote:
Hi,
I'm using the cache block of the enterprise lib Jan. 2006.
There is somethings strange going on.
I add a varable to the cache, let's say the string myData.
string myData = "1111111";
primitivesCache.Add("Key1", myData, CacheItemPriority.Normal, null, new
SlidingTime(TimeSpan.FromMinutes(15)));
When I do after this line this:
myData = "*****";
And I get my data out of the cache manager then myData has the value of
*********. I also tried to load it inside an other variable. Again the
value is the same.
How is it posible that the data in the cache is changed? Or not added
liked I did?
Please post a short but complete program that demonstrates your
problem. See Jon Skeet's page for a description of what constitutes a
"short but complete program":
http://www.yoda.arachsys.com/csharp/complete.html
What type is the variable?
Is it a string, like the code in your original post? Or is it one of
your own classes? If it is an object of your own type (class) then I
know why....
Arjen wrote:
Well, I found the problem... still strange...
I add an item to the cache.
After that I change the item, and also the item in the cache is changed
(why?).
Now I have made a copy of the variable after I add it to the cache.
This works fine.
Thanks.
Arjen
Bruce Wood wrote:
Arjen wrote:
Hi,
>
I'm using the cache block of the enterprise lib Jan. 2006.
>
There is somethings strange going on.
>
I add a varable to the cache, let's say the string myData.
string myData = "1111111";
primitivesCache.Add("Key1", myData, CacheItemPriority.Normal, null, new
SlidingTime(TimeSpan.FromMinutes(15)));
>
When I do after this line this:
myData = "*****";
>
And I get my data out of the cache manager then myData has the value of
*********. I also tried to load it inside an other variable. Again the
value is the same.
>
How is it posible that the data in the cache is changed? Or not added
liked I did?
Please post a short but complete program that demonstrates your
problem. See Jon Skeet's page for a description of what constitutes a
"short but complete program": http://www.yoda.arachsys.com/csharp/complete.html
Hi,
It's an arraylist with my own objects (classes).
So, it sounds like you know why...
Thanks,
Arjen
Bruce Wood wrote:
What type is the variable?
Is it a string, like the code in your original post? Or is it one of
your own classes? If it is an object of your own type (class) then I
know why....
Arjen wrote:
Well, I found the problem... still strange...
I add an item to the cache.
After that I change the item, and also the item in the cache is changed
(why?).
Now I have made a copy of the variable after I add it to the cache.
This works fine.
Thanks.
Arjen
Bruce Wood wrote:
Arjen wrote:
Hi,
I'm using the cache block of the enterprise lib Jan. 2006.
There is somethings strange going on.
I add a varable to the cache, let's say the string myData.
string myData = "1111111";
primitivesCache.Add("Key1", myData, CacheItemPriority.Normal, null, new
SlidingTime(TimeSpan.FromMinutes(15)));
When I do after this line this:
myData = "*****";
And I get my data out of the cache manager then myData has the value of
*********. I also tried to load it inside an other variable. Again the
value is the same.
How is it posible that the data in the cache is changed? Or not added
liked I did?
>
Please post a short but complete program that demonstrates your
problem. See Jon Skeet's page for a description of what constitutes a
"short but complete program":
> http://www.yoda.arachsys.com/csharp/complete.html
It's because what is cached is a _reference_ to the object instance.
Class instance are _reference types_, so your local variable and the
cache both store the same thing: a reference (or, if you prefer, a
pointer) to the same object in memory. Change the state (contents) of
the object, and it changes in both places because there is only one
object.
If you want to cache a copy of the object, not a reference to the same
object you're holding, then your class has to implement ICloneable and
you have to cache myObject.Clone(), not myObject.
Arjen wrote:
Hi,
It's an arraylist with my own objects (classes).
So, it sounds like you know why...
Thanks,
Arjen
Bruce Wood wrote:
What type is the variable?
Is it a string, like the code in your original post? Or is it one of
your own classes? If it is an object of your own type (class) then I
know why....
Arjen wrote:
Well, I found the problem... still strange...
I add an item to the cache.
After that I change the item, and also the item in the cache is changed
(why?).
Now I have made a copy of the variable after I add it to the cache.
This works fine.
>
Thanks.
Arjen
>
>
Bruce Wood wrote:
Arjen wrote:
Hi,
>
I'm using the cache block of the enterprise lib Jan. 2006.
>
There is somethings strange going on.
>
I add a varable to the cache, let's say the string myData.
string myData = "1111111";
primitivesCache.Add("Key1", myData, CacheItemPriority.Normal, null, new
SlidingTime(TimeSpan.FromMinutes(15)));
>
When I do after this line this:
myData = "*****";
>
And I get my data out of the cache manager then myData has the value of
*********. I also tried to load it inside an other variable. Again the
value is the same.
>
How is it posible that the data in the cache is changed? Or not added
liked I did?
Please post a short but complete program that demonstrates your
problem. See Jon Skeet's page for a description of what constitutes a
"short but complete program": http://www.yoda.arachsys.com/csharp/complete.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bite My Bubbles |
last post by:
I found the answer!
It is a IIS 6 /ASP problem
http://support.microsoft.com/default.aspx?scid=kb;en-us;332075
|
by: Joe Fallon |
last post by:
I am trying to setup a cache that refreshes itself every hour. (My sample
code is for every minute so I can test it.)
I have found some examples that I thought worked but they all seem to fail....
|
by: Fernando Chilvarguer |
last post by:
Hi,
I'm retriving data from a database and storing it on the Cache Object using
the following code:
HttpContext.Current.Cache.Insert(
cacheItemKey,
contentDS, //THE DATASET WITH MY DATA...
|
by: Adam |
last post by:
On an xp machine, the caching works as expected. I have deployed to a win2k
server, and an item I add to the cache expires almost immediately some times
and in under a minute in other times. The...
|
by: Aryan |
last post by:
Hi,
I have problem related to Caching of data. I am reading large xml
file and putting this xml in dataset, since this dataset will contain
many datatable's inside. And each datatable might be big...
|
by: =?Utf-8?B?ZGF2ZQ==?= |
last post by:
I have an asp.net project with a business layer (project) that has a class
called references. It loads up a data set and stores in cache with the
following code.
_cached =...
|
by: moondaddy |
last post by:
I had to repost this because I had to update and change my msdn alias. I
will re-ask the question and clarify a few things that were not clear
before.
This code is all executed on my dev...
|
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: Hypnotik |
last post by:
My program is to simulate cache memory. I read in the info from 2 external files, 1) access 2) data in memory. When I read the information in I display the info...and it is all correct. However...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
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: 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: 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: 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...
|
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: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
| |