public class ResultCache extends Object
JLanguageTool
objects only if
the JLanguageTool objects all use the same rules. For example, if you call JLanguageTool.addRule()
in different ways for the different instances that you use the same cache for, the cache will return invalid results.
Using a cache with bitext rules isn't supported either.
It is okay however, to use the same cache for JLanguageTool
objects with different languages, as
cached results are not used for a different language.Constructor and Description |
---|
ResultCache(long maxSize)
Create a cache that expires items 5 minutes after the latest read access.
|
ResultCache(long maxSize,
long expireAfter,
TimeUnit timeUnit) |
Modifier and Type | Method and Description |
---|---|
List<RuleMatch> |
getIfPresent(org.languagetool.InputSentence key) |
AnalyzedSentence |
getIfPresent(org.languagetool.SimpleInputSentence key) |
com.google.common.cache.Cache<org.languagetool.InputSentence,List<RuleMatch>> |
getMatchesCache() |
com.google.common.cache.Cache<org.languagetool.InputSentence,Map<String,List<RuleMatch>>> |
getRemoteMatchesCache() |
com.google.common.cache.Cache<org.languagetool.SimpleInputSentence,AnalyzedSentence> |
getSentenceCache() |
long |
hitCount() |
double |
hitRate() |
void |
put(org.languagetool.InputSentence key,
List<RuleMatch> sentenceMatches) |
void |
put(org.languagetool.SimpleInputSentence key,
AnalyzedSentence aSentence) |
double |
requestCount() |
public ResultCache(long maxSize)
maxSize
- maximum cache size in number of sentencespublic ResultCache(long maxSize, long expireAfter, TimeUnit timeUnit)
maxSize
- maximum cache size in number of sentencesexpireAfter
- time to expire sentences from the cache after last read accesspublic double hitRate()
public double requestCount()
public long hitCount()
public AnalyzedSentence getIfPresent(org.languagetool.SimpleInputSentence key)
public void put(org.languagetool.SimpleInputSentence key, AnalyzedSentence aSentence)
public com.google.common.cache.Cache<org.languagetool.InputSentence,List<RuleMatch>> getMatchesCache()
public com.google.common.cache.Cache<org.languagetool.InputSentence,Map<String,List<RuleMatch>>> getRemoteMatchesCache()
public com.google.common.cache.Cache<org.languagetool.SimpleInputSentence,AnalyzedSentence> getSentenceCache()