SysCache re-caches items without expiration policy

Description

Hi,

Following on from [url=http://forum.hibernate.org/viewtopic.php?t=959404&highlight=softquerycache]my post/url which was causing an ever growing amount of memory in NHibernate when using HQL queries, I have found two bugs in the SysCache implementation. I have written and tested a patch for SysCache which fixes these:

1) When an item is placed into the cache, if it does not already exist it is added with an expiration policy. If the item does exist, it is placed into the cache without an expiration policy - this means that the item lives until the garbage collector decides to remove it. I have modified the Put method so that if the key is already contained in the cache, it is removed and the new item can be inserted with an expiration policy.

2) When an item was being overwritten in the cache (Cache[key]=value) it caused the callback to fire which would delete the _map reference to the key. As the item was then being added into the cache, this meant the _map set of keys would not be synchronised. I've changed this to use cache dependancies:- when the cache is created a root cache node is created which all items in the cache become dependant upon. When the Clear method is called it removes the root cache node, causing all dependant cache items to be removed. This removes the requirement for the Hashtable _map which contained a list of all keys added by the cache instance.

I've attached the unit test and patch for both issues.

Al

Environment

None

Attachments

1

Activity

Former user July 31, 2006 at 1:18 AM

Fixed in 1.0.3

Former user June 2, 2006 at 6:37 AM

Reopening to fix in 1.0.3

Former user May 22, 2006 at 7:55 AM

Thanks, I'll take a look at it.

Fixed

Details

Assignee

Reporter

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created May 22, 2006 at 7:50 AM
Updated July 12, 2008 at 1:41 PM
Resolved July 31, 2006 at 1:18 AM
Who's Looking?