开发者

Managing entities in NHibernate 1st level cache

开发者 https://www.devze.com 2023-01-16 22:42 出处:网络
What\'s the proper way to manage persisted entities in the 1st level cache during thread/session lifetime? Actually, there is only one or two persisted instances per thread (session) that should be pr

What's the proper way to manage persisted entities in the 1st level cache during thread/session lifetime? Actually, there is only one or two persisted instances per thread (session) that should be present at all times, for referencing them from other (transient) entities before saving.

Since I need to clear the session cache every once in a while (because otherwise it gets filled and painfully slow), wha开发者_如何学Pythont I am not sure is - should I:

  1. Evict all entities from the session, except the ones I need?
  2. Clear the entire session, and reload necessary entities?
  3. Create a new session and reload necessary entities?


I think you should close previous Session and open new one. If objects that you want to cache are heavy for loading per each session you sould use Second level caching.

0

精彩评论

暂无评论...
验证码 换一张
取 消