Link to home
Start Free TrialLog in
Avatar of Paramhans
Paramhans

asked on

how does it work ???

Hi,
   I have a situation as follows :

I have a bunch of my website settings which i named it as WebSettings (a class which holds all these settings).

I create object of this class on first call and store it in Cache object for all future uses.


Now one browser is accessing the Value of a particular setting from Cache.

Meanwhile i changed the system setting value and new browser is opened to access the setting.

My question is is there 2 different copies of Cache available for 2 browser instances or Cache would be same.
Avatar of angus_young_acdc
angus_young_acdc
Flag of United Kingdom of Great Britain and Northern Ireland image

From memory you would have to create two seperate caches, otherwise it will all be stored in 1 default cache where if one browser changes a value (and stores it in the cache) then the 2nd browser would read the updated value.
This depends on how you are storing it, i presume your using HttpContext.Current.Cache.
What are you using as the Key ?
Avatar of AmarIs26
AmarIs26

Cache is global just like Application object. It is optimised for faster and safer read/write. So if you need to store something that will be used by all users then use cache. However if you need to use settings which are per user, then you should make use of the Session which is user specific.

1 Cache -> Shared by All browsers/users
1 Session -> Shared by one user/ One unique instance of the browser
1 Application -> Shared by all browsers/users
It might be ok to use a database table and store the settings there.  If you wanted to keep the settings the same across all instances of your application you would just load the data everytime from the database.  You could version the data or setup temp areas where settings can change on a per user basis or allow global changes.  That way you have complete control over the data and can even load that data into a memory (class / struct) as needed.  
Avatar of Paramhans

ASKER

Hi thanx 4 the replies.

But to be very precise i want answer to my question.

My question is is there 2 different copies of Cache available for 2 browser instances or Cache would be same.

thanx in advance
ASKER CERTIFIED SOLUTION
Avatar of AmarIs26
AmarIs26

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial