I understand that NHibernate’s 2nd level cache works at the SessionFactory level. I’m using a connection provider in my NHibernate configuration to work with my multi-tenant environment. I’m wondering how the 2nd level cache interacts with the connection provider. That is, does it intelligently maintain a cache for each separate connection string, or do all connections share the same cache?
Obviously sharing the same cache is a huge no-no since the same query will return different results based on the database it is hitting.
So 2nd level works only thru sessions of the same session factory.
Please look First and Second Level caching in NHibernate for more details