Never use a Global/Application Persistence Manager!
PersistenceManager is not thread safe and very bad things will happen if you try to share entities across sessions.
A Session-level PersistenceManager that is held in server memory between requests is technically fine although you may question whether and to what degree that is scalable enough for your use. We do show this approach in our ASP.NET demonstrations ... but one should really understand the issues and appropriateness for your application before mimicking it.
I quite understand the desire to cache stable, reference entities on the middle tier rather than keep going to the Data Tier for them. The collection of US States is not likely to change for some time.
This can be done but you have to use EntityCacheState and write thread safe code (especially if the reference entities MIGHT change between middle tier re-cycling). This topic is advanced and should only be considered once you have demonstrated with metrics that (a) you are putting overwhelming pressure on the data tier with repeated requests for the same entities and (b) the database pressure would be substantially relieved if these entities were cached in the middle tier.
These propositions seem true on paper; not true very often in practice.
We can take a crack at options ... once someone shows me some measurements that justify the effort. I'm not trying to hide anything. Just seen too many folks chase this rat down the hole at the expense of adding business value to the application. My $0.02.
|