Hi Everyone -
Here is my question(s)
I have a web service that needs to keep a table in memory (hash table) and when a client connects
and requests a token, a GUID is generated and placed into the hash table and returned to the caller.
Is there a way to create this hash table in global memory (like a critical section) that can be used by
each instance of the web service client calling?
thanks
tony
pithhelmet:
Is there a way to create this hash table in global memory (like a critical section) that can be used by
each instance of the web service client calling?
Place it in Application memory.. You could simply cast it and read it back
when you are setting it .. place the hashtable in the application state bag as follows
Application["testTable"] = yourHashTable;
when you read simply cast the application state item into hashtable
if(Application["testTable"] != null)
{
Hashtable ht = (Hashtable)Application["testTable"];
}
Hi -
Thanks for a great answer...
application state bag... please elaborate on where this is created?
thanks
tony
This is created in the application memory.. to be precise, inside the appDomain memory space.. so its available for all the user sessions
Right - thanks for the additional response.
In code, where do i create the hash table?
thanks
tony
Since you are going to use the same hashtable through out your application.. you can create the hashtable in Application_Start event handler in Global.asax and use it wherver you add record or retrieve record
0 comments:
Post a Comment