473,748 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Lock cache while updating it?

I am caching some data in VB.NET using System.Web.Cach ing, is it possible to
lock the cache so that other sessions attempting to access the same cache
wait when it is being updated? I have the cache using a sliding timeout and
a dependency on the text file its data is extracted from.
If it's relevant, based on current statistics, I do not expect more than
about 400 people to be accessing the web site at the same time.
I've seen it appears easy in C# but I couldn't find anything regarding VB.

Andrew
Nov 21 '05 #1
13 2344
Andrew,

You make me curious, why would you do that? Seems to me a strange solution,
because you should than make a mechanisme for those other 399 who try to
access that cache in my idea. When it is, than what it the action on that
catch?

I am real curious about this how you did that.

Cor
Nov 21 '05 #2
Cor Ligthert wrote:
Andrew,

You make me curious, why would you do that? Seems to me a strange
solution, because you should than make a mechanisme for those other
399 who try to access that cache in my idea. When it is, than what it
the action on that catch?

I am real curious about this how you did that.

Cor


The cached data is a lookup table which has the same data for every user.
The cache applies to the web application rather than per-session. Unless I
have misunderstood the docs.

Andrew
Nov 21 '05 #3
Andrew,

Clear,

Is it than not something as updating the tables, create a page to kill the
cache and let it go again, where I assume that the cache is created when it
is nothing?

I never used that cache, however that is from what I understand from it,
would probably as first try to do it.

Cor
Nov 21 '05 #4
> Is it than not something as updating the tables, create a page to
kill the cache and let it go again, where I assume that the cache is
created when it is nothing?


Imagine this scenario:-
--------------------------
session1 starts and finds the cache is nothing and starts parsing the data
to create the cache

While session1 is parsing the data, session2 starts and finds the cache is
nothing, so it starts parsing the data to create the cache

session1 finishes parsing the data and creates the cache

session2 finishes parsing the data and creates the cache, except session1 is
still writing the cache so something goes wrong
--------------------------

Preferred scenario:-

session1 starts and finds the cache is nothing, locks the cache and starts
parsing the data to create the cache

While session1 is parsing the data, session2 starts and finds the cache is
locked, so it waits until the cache is unlocked.

Andrew
Nov 21 '05 #5
JD
The MSDN docs say Cache is thread safe.

"Andrew Morton" <ak*@in-press.co.uk.inv alid> wrote in message
news:eu******** ******@TK2MSFTN GP15.phx.gbl...
I am caching some data in VB.NET using System.Web.Cach ing, is it possible to lock the cache so that other sessions attempting to access the same cache
wait when it is being updated? I have the cache using a sliding timeout and a dependency on the text file its data is extracted from.
If it's relevant, based on current statistics, I do not expect more than
about 400 people to be accessing the web site at the same time.
I've seen it appears easy in C# but I couldn't find anything regarding VB.

Andrew

Nov 21 '05 #6
Andrew,

Did you test this and did it work as you describe. For me is the problem
that somebody once wrote here that an aspnet dll is running itself
automaticly on more threads for sessions.

When that is not true, than in my opinion can the effect not be as you
write.
However I never saw any documentation which tells something about the proces
of a webapplication dll.

Sorry

Cor
Nov 21 '05 #7
JD wrote:
The MSDN docs say Cache is thread safe.


How do I use that to make other threads pause when one thread is updating
the cache?

However, looking through the docs about thread safety lead me to SyncLock,
which I think is what I want.

Andrew
Nov 21 '05 #8
JD
The Cache automatically synchronizes access to the data. I believe it uses a
multireader, single writer lock. In other words you don't have to do
anything.

"Andrew Morton" <ak*@in-press.co.uk.inv alid> wrote in message
news:uC******** ******@TK2MSFTN GP10.phx.gbl...
JD wrote:
The MSDN docs say Cache is thread safe.


How do I use that to make other threads pause when one thread is updating
the cache?

However, looking through the docs about thread safety lead me to SyncLock,
which I think is what I want.

Andrew

Nov 21 '05 #9
JD
But let me emphasize, the block of code that does -> {check if the cache
data is Nothing and if it is Nothing do the update to cache } must be
synchonized.
"JD" <an**@anon.anon > wrote in message
news:uQ******** ******@TK2MSFTN GP10.phx.gbl...
The Cache automatically synchronizes access to the data. I believe it uses a multireader, single writer lock. In other words you don't have to do
anything.

"Andrew Morton" <ak*@in-press.co.uk.inv alid> wrote in message
news:uC******** ******@TK2MSFTN GP10.phx.gbl...
JD wrote:
The MSDN docs say Cache is thread safe.


How do I use that to make other threads pause when one thread is updating the cache?

However, looking through the docs about thread safety lead me to SyncLock, which I think is what I want.

Andrew


Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9527
by: xixi | last post by:
can someone explain to me what is internal p lock, internal s lock, internal v lock? when i have IS lock or IX lock , i always have these internal locks together for the application handle Application handle = 261 Application ID = AC100482.GD3A.00F85FE51898 Sequence number = 0006 Application name = db2jccmain Authorization ID ...
9
7363
by: Jane | last post by:
Our db2diag.log is full of messages like this: 2004-05-31-17.15.10.383766 Instance:tminst1 Node:000 PID:394948(db2agent (TMDB1) 0) TID:1 Appid:GA140956.EF26.03A4B1202647 data management sqldEscalateLocks Probe:3 Database:TMDB1 ADM5502W The escalation of "4759" locks on table "I2TM .SHPM_T" to lock intent "S" was successful. The message is always about Shared locks. What can I do to eliminate these errors?
6
437
by: n_o_s_p_a__m | last post by:
I have seen some debate but am not clear on what the problematic implications of the expression lock(this) are. Microsoft seems to advocate it, but others seem to be against it. Pros and cons? -KJ
4
5368
by: Mat | last post by:
Hi, I've stumbled onto a problem when using the caching object in ASP.Net. I'm placing a static dataset to the cache as the data only changes once a day. Whilst writing to the cache I'm using a lock using code like below (just typed this in); Cache thisCache = HttpContext.Current.Cache lock(thisCache)
5
1939
by: Lloyd Dupont | last post by:
in an ASP.NET page I have some static method which get value for the cache or, if the cache is empty, query the database, put the value in the cache and return it. because ASP.NET is thread intensive I was thinking to lock these method, using a fine grained lock. the best lock I was thinking about was the string key in the cache! however I have one concern, these unique string might be used in other lock, could they? could this be a...
3
6662
by: Raj | last post by:
I created a refresh deferred MQT, and during full refresh there were 4 or 5 lock waits, all waiting on a 'S' lock on Internal Catalog Cache ? Can some one explain how to prevent this from happening?
2
4703
by: archana | last post by:
Hi all, I am having application wherein i am using asynchronous programming and using callback i am updating one label control. My question is can i use lock statment to lock control. If yes which one is better to prevent unpredictable update of label. Whether should i use lock statement or control.invoke and give method name. Please correct me if i am wrong.
94
30335
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock Statement (C# Reference) statement to serialize access. " But when is it better to use "volatile" instead of "lock" ?
0
8822
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9310
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,...
0
8235
agi2029
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...
1
6792
isladogs
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...
0
6072
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();...
0
4592
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.