0

I am using Java 11 for my application. I want to store the log lines in Google guava cache with limit as 5000 and write it to file after the limit is reached with synchronized.

CacheLoader used key value pair. I don't have both. I have only one log lines.

Will I able to achieve it using Google guava cache?

Galet
  • 5,853
  • 21
  • 82
  • 148
  • I doubt Cache is the data structure you want. For starters it won't preserve the order of your log lines. Why not just use a List or Queue, and write the `if (lines.size() >= 5000)` check yourself? – MikeFHay Sep 17 '20 at 12:50
  • my application is used for multithreaded environment. I want to know , will google guava cache support my scenario? – Galet Sep 17 '20 at 12:52
  • Can you show sample code? – Grzegorz Rożniecki Sep 17 '20 at 16:18

0 Answers0