asp.net - Cache items corrupt or mixed up -


i have strange problem website several objects cached. have lot of datatables, strings, booleans , other stuff cached quick fetching in later requests.

sometimes periodic error looks of cache items have been mixed up. example of how shows when piece of code fetches datatable cache , tries access column of datatable. see yellow screen of death exception "cannot find column [columnname]", "columnname" of course column name supposed in datatable. when inspect cache item little home made tool, see different datatable in cache item. of cache items have been mixed up.

does have idea how happens?

we not able reproduce error. occurs @ apparently random intervals.

whats issue

when add items cache, need lock process create them , added cache.

first lets clarify cache keep reference data, not clone them, nether knows whats not data ! reference: http://msdn.microsoft.com/en-us/library/6hbbsfk6(vs.71).aspx

second clarify default session of page lock pages , make of request safe because users lock until page load , send.

when appear

so lock issue may appear when try make cache thread, or handler, or page have session off.

how lock

if use 1 pool, simple lock(object){} can work, if use many pools need use mutex() lock

you need lock full process of making data if change them later , still existing on cache, or cache reference if make clone of them.

for example, if read data have cache, time edit them, if other read same cache corrupted data, because cache give reference them.

hope helps.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -