class PriorityDateComparer has error in the Cache Block

Topics: Caching Application Block
Oct 20, 2010 at 8:06 AM

in line 72:

 if (rightCacheItem== null && leftCacheItem== null)
                    {
                        return 0;
                    }
                    if (leftCacheItem== null)
                    {
                        return -1;
                    }
                    if (rightCacheItem== null)
                    {
                        return 1;
                    }

 

the rightCacheItem and leftCacheItem are not null.

the code should be :

 if (rightCacheItem.Value == null && leftCacheItem.Value == null)
                    {
                        return 0;
                    }
                    if (leftCacheItem.Value == null)
                    {
                        return -1;
                    }
                    if (rightCacheItem.Value == null)
                    {
                        return 1;
                    }

Oct 21, 2010 at 1:38 AM

If you do that, then the priority and last accessed time of cache items with null value will get ignored.  The intent of the PriorityDateComparer, as its name suggests, is to sort based on date and priority.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Oct 21, 2010 at 2:40 AM

I think the cache with null value is invalid, that should be first  to clear .

Is not it?

Oct 21, 2010 at 3:08 AM
Edited Oct 21, 2010 at 3:10 AM

I don't know if it is considered that a cache item having a null value is a valid scenario.   We'll just confirm this with the EntLib Team.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Feb 7, 2011 at 11:52 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.