I'm creating a web service and I need to map a bunch of String names to set of database names. That is, a request will arrive with a data item, and I need to figure out which database it maps to.
To create this mapping, I need to query the database also, preferably only once. I want to be able to access this mapping whenever requests come in and not have to construct my map on each request. What I don't want, is to have to query the database 10 times every 10 seconds, which is potentially what could happen, in this case.
I considered storing the map as a static member variable upon the first request. So my question is - are there any known issues with having this map as static and sharing across requests?
As long as you only fill this static structure at startup (and don't expect it to change during the lifetime of the service) there are no issues with this. Specifically the only situations where this might be a problem are:
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments