mirror of https://github.com/apache/lucene.git
SOLR-2135: Fix behavior of ConcurrentLRUCache when asking for getLatestAccessedItems(0) or getOldestAccessedItems(0)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1003703 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
de8177af00
commit
1cdc4e655e
|
@ -505,6 +505,10 @@ Bug Fixes
|
|||
wildcard support. For example, a query of *zemog* would match documents that contain
|
||||
'gomez'. (Landon Kuhn via Robert Muir)
|
||||
|
||||
* SOLR-2135: Fix behavior of ConcurrentLRUCache when asking for
|
||||
getLatestAccessedItems(0) or getOldestAccessedItems(0).
|
||||
(David Smiley via hossman)
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -398,6 +398,8 @@ public class ConcurrentLRUCache<K,V> {
|
|||
*/
|
||||
public Map<K, V> getOldestAccessedItems(int n) {
|
||||
Map<K, V> result = new LinkedHashMap<K, V>();
|
||||
if (n <= 0)
|
||||
return result;
|
||||
TreeSet<CacheEntry> tree = new TreeSet<CacheEntry>();
|
||||
markAndSweepLock.lock();
|
||||
try {
|
||||
|
@ -424,6 +426,8 @@ public class ConcurrentLRUCache<K,V> {
|
|||
|
||||
public Map<K,V> getLatestAccessedItems(int n) {
|
||||
Map<K,V> result = new LinkedHashMap<K,V>();
|
||||
if (n <= 0)
|
||||
return result;
|
||||
TreeSet<CacheEntry> tree = new TreeSet<CacheEntry>();
|
||||
// we need to grab the lock since we are changing lastAccessedCopy
|
||||
markAndSweepLock.lock();
|
||||
|
|
|
@ -243,6 +243,14 @@ public class TestFastLRUCache extends LuceneTestCase {
|
|||
assertNotNull(m.get(5));
|
||||
assertNotNull(m.get(4));
|
||||
assertNotNull(m.get(2));
|
||||
|
||||
m = cache.getOldestAccessedItems(0);
|
||||
assertTrue(m.isEmpty());
|
||||
|
||||
//test this too
|
||||
m = cache.getLatestAccessedItems(0);
|
||||
assertTrue(m.isEmpty());
|
||||
|
||||
cache.destroy();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue