Package org.languagetool
Class ResultCache
java.lang.Object
org.languagetool.ResultCache
A cache to speed up text checking for use cases where sentences are checked more than once. This
typically happens when using LT as a server and texts get re-checked after corrections have been applied
for some sentences. Use the same cache object for all
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.- Since:
- 3.7
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class
(package private) class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final com.google.common.cache.Cache
<InputSentence, List<RuleMatch>> private final com.google.common.cache.Cache
<SimpleInputSentence, AnalyzedSentence> -
Constructor Summary
ConstructorsConstructorDescriptionResultCache
(long maxSize) Create a cache that expires items 5 minutes after the latest read access.ResultCache
(long maxSize, long expireAfter, TimeUnit timeUnit) -
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.cache.Cache
<InputSentence, List<RuleMatch>> com.google.common.cache.Cache
<SimpleInputSentence, AnalyzedSentence> long
hitCount()
double
hitRate()
void
put
(InputSentence key, List<RuleMatch> sentenceMatches) void
put
(SimpleInputSentence key, AnalyzedSentence aSentence) double
-
Field Details
-
matchesCache
-
sentenceCache
-
-
Constructor Details
-
ResultCache
public ResultCache(long maxSize) Create a cache that expires items 5 minutes after the latest read access.- Parameters:
maxSize
- maximum cache size in number of sentences
-
ResultCache
- Parameters:
maxSize
- maximum cache size in number of sentencesexpireAfter
- time to expire sentences from the cache after last read access
-
-
Method Details
-
hitRate
public double hitRate() -
requestCount
public double requestCount() -
hitCount
public long hitCount() -
getIfPresent
-
getIfPresent
-
put
-
put
-
getMatchesCache
- Since:
- 4.1
-
getSentenceCache
- Since:
- 4.1
-