Caching cause leaking of entities data from one session factory to another

Description

Assuming that I've an Employee #5 in two session factories, and caching is enabled, it is possible that data that was loaded in one session factory will be returned from the second.
This is because the generated cache key is the same, and the cache space is shared in all implementations.

Should use the session factory name to distingiush between the caches, since that will allow using the cache in distributed scenarios yet maintain the seperation between seperate session factories.

Environment

None

Attachments

3

Activity

Dana Naideth May 4, 2009 at 11:52 AM

I know this is a closed issue, but I thought I would answer my own question in case anybody finds this. For NH 2.0, ICacheProvider.BuildCache() still has the following signature:

ICache BuildCache(string regionName, IDictionary<string,string> properties)

However, the regionName that NH passes to the provider already includes the prefix. For example, if regionPrefix was "TestPfx", and NH wanted to create a region named "Default", it would read the regionPrefix and create a cache named "TestPfx.Default".

Also, I noticed that ICacheProvider has a Start() method with the following signature:

void Start(IDictionary<string, string> properties)

From here, you can use "Environment.CacheRegionPrefix" as the key to obtain the configured regionPrefix. Once you have the configured regionPrefix, follow the same naming pattern to configure your own caches.

Kind of neat.

Dana Naideth April 7, 2009 at 9:59 AM

I am in the process of implementing a cache provider and noticed that the ICacheProvider.BuildCache() still has the following signature for NH 2.0:

ICache BuildCache(string regionName, IDictionary<string,string> properties)

Is this the case? If so, how would I go about getting these changes applied to the 2.0 branch?

Many thanks?

OrenE December 8, 2006 at 12:20 PM

Fixed in 2524

OrenE December 8, 2006 at 12:19 PM

more specifically, I am talking about it not being used for entities.
For query cache, it is used, but not when storing the entity data itself.

OrenE December 8, 2006 at 12:17 PM

Looks like this is really an issue, the caches are not using regionPrefix, although it is passed to them.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Priority

Who's Looking?

Open Who's Looking?
Created September 29, 2006 at 5:59 AM
Updated April 6, 2011 at 11:21 AM
Resolved December 8, 2006 at 12:20 PM
Who's Looking?