Back to LanguageTool Homepage - Privacy - Imprint

A new cache in LT

Hi,

I’ve added a class ResultCache that can be used to speed up checking if sentences get checked more than once. The HTTP server already uses this. Checking a sentence more than once is actually common when a user makes corrections based on LT’s suggestion but the whole text needs to be re-checked.

The original idea was to cache the results for every sentence, but this won’t work correctly with rules that work on the text level instead of the sentence level. So for now, only the analyzed sentence is cached and the rules still need to run. Yet, for languages with a slow analysis like English the cache can help a lot. Maybe I manage to cache rule matches too (minus the sentence-level ones).

Regards
Daniel

The first phase (caching the sentence analysis) is now active on languagetool.org. Please let me know if you experience issues or unusual behavior. The next phase (also caching the error rule matches) will be turned on tomorrow.

1 Like

Hi Daniel,

How long the cached sentences are kept in memory? Is there any invalidation mechanism?

5 minutes. If a sentence is requested again in those 5 minutes, the counting starts from 0 again.

1 Like

Is 5 minutes is default behaviour or we have to add some extra parameters for this to happen?

In LanguageTool, I found the parameters are passed to request and handled with ResultCache.

Can you please give me an example (for parameter to be passed) to check with it. I can’t find it in any help docs.

If you’re using the server, you have to set cacheSize in the config properties file for the cache to be active. In all other cases, AFAIR, it’s not active.