New items with same ids as deleted items cannot be cached until cache.expiration windows ends

Description

I have defined an entity that is configured to be cached and if I delete an existent entity lets say with ID equal to 1 that was cached before and then create a new entity with id equal to 1 and save it than the new entity is not stored in the second level cache until the cache expire window for the deleted entity ends.

You maybe wonder why would I want to reuse IDs. I'm creating a .NET Session State Provider that use NHibernate to store session in the database. If I'm calling Session.Abandon the session will get deleted from the database and the cache for the corresponding ID will be invalidated but wont be deleted until the cache expires time frame ends. If I navigate to another page that writes something in session than a new session will be created in the database with the same ID (since asp.net will send me the same id) as the one that was deleted. If this happens before the cache expires time frame ends then it wont get cached. And this is problematic because all the queries will hit the database for 20 minutes which is the cache expire value for my entities.

Environment

None

Activity

Show:

Fabio Maulo October 31, 2010 at 11:33 AM

Thanks for the information.

Emilian Balanescu October 19, 2010 at 9:08 AM

After more research it turns out not to be a real bug. In the code I'm calling session.Get before creating the new session and the empty result gets cached.

Still it would be nice to have an option to exclude empty results from being cached.

Not an Issue

Details

Assignee

Reporter

Components

Priority

Who's Looking?

Open Who's Looking?
Created October 19, 2010 at 7:00 AM
Updated October 31, 2010 at 11:33 AM
Resolved October 31, 2010 at 11:33 AM
Who's Looking?