S
Simon Woods
Hi
I am developing a webservice. I need to authenticate webrequests. I am
using a dictionary to keep track of authenticated users. In order to do
this, prior to adding an entry into the dictionary I need to perform
some DB access to validate the user.
Because it is a webservice, I am slightly concerned about threadsafety,
particularly race conditions which may arise when an authentication has
expired and I need to remove it from the dictionary.
I have found several implementations of threadsafe dictionaries which
use locks to maintain threadsafety, but obviously I need to include the
DB checking within the threadsafety mechanism.
I know I could modify the implementation of the dictionary to include
db access, but I don't think that is the best way, and I would rather
find another way whereby I either inherit the threadsafe dictionary into
another threadsafe container - but then it seems that there'd be 2
levels of locking.
I haven't used delegates that much and was wondering if I could use
delegates to effectively "transactionalise" the db access/adding to
dictionary but I'm not sure if they would give me the threadsafety I am
after.
Appreciate any suggestions, pointers to articles etc.
Many Thx
Simon
I am developing a webservice. I need to authenticate webrequests. I am
using a dictionary to keep track of authenticated users. In order to do
this, prior to adding an entry into the dictionary I need to perform
some DB access to validate the user.
Because it is a webservice, I am slightly concerned about threadsafety,
particularly race conditions which may arise when an authentication has
expired and I need to remove it from the dictionary.
I have found several implementations of threadsafe dictionaries which
use locks to maintain threadsafety, but obviously I need to include the
DB checking within the threadsafety mechanism.
I know I could modify the implementation of the dictionary to include
db access, but I don't think that is the best way, and I would rather
find another way whereby I either inherit the threadsafe dictionary into
another threadsafe container - but then it seems that there'd be 2
levels of locking.
I haven't used delegates that much and was wondering if I could use
delegates to effectively "transactionalise" the db access/adding to
dictionary but I'm not sure if they would give me the threadsafety I am
after.
Appreciate any suggestions, pointers to articles etc.
Many Thx
Simon