moremind commented on issue #4475:
URL: https://github.com/apache/shenyu/issues/4475#issuecomment-1471406810

   > > It looks like the request is to use a weak cache for the static `ALL` 
field so that instances may be collected when there are no strong references 
held by the application. As this is a static field that can be called by 
multiple threads, it should also be thread-safe. It doesn't look like ordering 
matters, so you could use a Caffeine weakKey cache with 
`Collections.newSetFromMap`. Something like,
   > > ```java
   > > private static final Set<MemorySafeWindowTinyLFUMap<?, ?>> ALL = 
Collections.newSetFromMap(
   > >     Caffeine.newBuilder().weakKeys().<MemorySafeWindowTinyLFUMap<?, 
?>>build().asMap());
   > > ```
   > 
   > as I know, Caffeine cannot be memory safe,
   
   or catch Out Of Memory Error to release caffeine cache.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to