Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class LookupSetsManager

private LookupSetsManager()
{
_cache = CacheManager.getStringKeyCache(1000, CacheManager.UNLIMITED, "LookupSetsManagerCache");
_cache = CacheManager.getCache(String.class, 1000, CacheManager.UNLIMITED, "LookupSetsManagerCache");
}

public static LookupSetsManager get()
Expand Down
2 changes: 1 addition & 1 deletion jbrowse/src/org/labkey/jbrowse/JBrowseFieldUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

public class JBrowseFieldUtils
{
private static final Cache<String, Map<String, JBrowseFieldDescriptor>> _cache = CacheManager.getStringKeyCache(50000, CacheManager.DAY, "JBrowseFieldInfo");
private static final Cache<String, Map<String, JBrowseFieldDescriptor>> _cache = CacheManager.getCache(String.class, 50000, CacheManager.DAY, "JBrowseFieldInfo");

private static final Logger _log = LogHelper.getLogger(JBrowseFieldUtils.class, "Logger for JBrowseFieldUtils");

Expand Down
32 changes: 13 additions & 19 deletions jbrowse/src/org/labkey/jbrowse/JBrowseLuceneSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Stream;

import static org.labkey.jbrowse.JBrowseFieldUtils.VARIABLE_SAMPLES;
import static org.labkey.jbrowse.JBrowseFieldUtils.getSession;
Expand Down Expand Up @@ -507,37 +507,33 @@ public static class LuceneIndexCache implements Cache<String, CacheEntry>

public LuceneIndexCache()
{
_cache = CacheManager.getStringKeyCache(1000, CacheManager.UNLIMITED, "JBrowseLuceneSearchCache");
_cache = CacheManager.getCache(String.class, 1000, CacheManager.UNLIMITED, "JBrowseLuceneSearchCache");

}

@Override
public void remove(@NotNull String key)
public boolean remove(@NotNull String key)
{
CacheEntry e = get(key);
_cache.remove(key);
boolean ret = _cache.remove(key);

closeReader(e);

return ret;
}

@Override
public void clear()
{
for (String key : getKeys())
{
closeReader(get(key));
}
getKeys().forEach(key -> closeReader(get(key)));

_cache.clear();
}

@Override
public void close()
{
for (String key : getKeys())
{
closeReader(get(key));
}
getKeys().forEach(key -> closeReader(get(key)));

_cache.close();
}
Expand Down Expand Up @@ -590,7 +586,7 @@ public int removeUsingFilter(Predicate<String> filter)
}

@Override
public Set<String> getKeys()
public Stream<String> getKeys()
{
return _cache.getKeys();
}
Expand Down Expand Up @@ -640,8 +636,7 @@ public File getLuceneIndexDir()
public static JSONArray reportCacheInfo()
{
JSONArray cacheInfo = new JSONArray();
for (String sessionId : _cache.getKeys())
{
_cache.getKeys().forEach(sessionId -> {
LRUQueryCache qc = _cache.get(sessionId).getQueryCache();
JSONObject info = new JSONObject();
info.put("cacheSize", qc.getCacheSize());
Expand All @@ -651,7 +646,7 @@ public static JSONArray reportCacheInfo()
info.put("evictionCount", qc.getEvictionCount());
info.put("totalCount", qc.getTotalCount());
cacheInfo.put(info);
}
});

return cacheInfo;
}
Expand All @@ -677,14 +672,13 @@ public static void emptyCache()

public static void clearCacheForFile(@NotNull File luceneIndexDir)
{
for (String key : _cache.getKeys())
{
_cache.getKeys().forEach(key -> {
CacheEntry entry = _cache.get(key);
if (entry != null && luceneIndexDir.equals(entry.getLuceneIndexDir()))
{
_cache.remove(key);
}
}
});
}

public static void clearCache(@Nullable String jbrowseTrackId)
Expand Down
Loading