You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "dsmiley (via GitHub)" <gi...@apache.org> on 2026/06/09 19:44:31 UTC
[PR] Replace ConcurrentLRUCache and Cache interface with Caffeine [solr]
dsmiley opened a new pull request, #4516:
URL: https://github.com/apache/solr/pull/4516
I have replaced the custom `ConcurrentLRUCache` implementation and the `org.apache.solr.common.util.Cache` interface with Caffeine's `Cache` in `solr-core`.
Key changes:
1. **Refactored `solr-solrj`**:
* Refactored `JavaBinCodec.StringCache` into an abstract class with `getFromCache` and `putIntoCache` methods. This keeps `solrj` independent of Caffeine.
* Updated `ObjectCache` to use `ConcurrentHashMap` directly and fixed its `computeIfAbsent` methods to ensure compatibility with existing call-sites (like `IndexSchemaFactory`).
* Removed `org.apache.solr.common.util.Cache` and `MapBackedCache`.
2. **Updated `solr-core`**:
* Replaced `ConcurrentLRUCache` with Caffeine's `Cache` in `IndexSchema` and `TemplateUpdateProcessorFactory`.
* Deleted `org.apache.solr.util.ConcurrentLRUCache`.
3. **Updated Tests**:
* Modified `TestJavaBinCodec` to use a `HashMap`-based implementation of the now-abstract `StringCache`.
* Cleaned up test code that referenced the deleted cache classes.
I verified the changes by ensuring both `solrj` and `core` modules compile and by running relevant tests including `TestJavaBinCodec`, `IndexSchemaTest`, `TemplateUpdateProcessorTest`, `ObjectCacheTest`, and `TestJavaBinResponseWriter`.
---
*PR created automatically by Jules for task [10202347838202579826](https://jules.google.com/task/10202347838202579826) started by @dsmiley*
---
Fork PR: https://github.com/dsmiley/solr/pull/28
--
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: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] Replace ConcurrentLRUCache and Cache interface with Caffeine [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #4516:
URL: https://github.com/apache/solr/pull/4516#issuecomment-4753658291
Will merge Tuesday if no further feedback.
--
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: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] Replace ConcurrentLRUCache and Cache interface with Caffeine [solr]
Posted by "renatoh (via GitHub)" <gi...@apache.org>.
renatoh commented on code in PR #4516:
URL: https://github.com/apache/solr/pull/4516#discussion_r3448912212
##########
solr/core/src/java/org/apache/solr/update/processor/TemplateUpdateProcessorFactory.java:
##########
@@ -79,7 +79,7 @@ protected String getMyName() {
public static Resolved getResolved(
String template, Cache<String, Resolved> cache, Pattern pattern) {
- Resolved r = cache == null ? null : cache.get(template);
+ Resolved r = cache == null ? null : cache.getIfPresent(template);
Review Comment:
@dsmiley
With Caffeine-Cache we could do this fetch and then the put as an atomic operation:
https://javadoc.io/static/com.github.ben-manes.caffeine/caffeine/2.9.0/com/github/benmanes/caffeine/cache/Cache.html#get-K-java.util.function.Function
What do you think?
--
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: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] Replace ConcurrentLRUCache and Cache interface with Caffeine [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #4516:
URL: https://github.com/apache/solr/pull/4516#discussion_r3449016159
##########
solr/core/src/java/org/apache/solr/update/processor/TemplateUpdateProcessorFactory.java:
##########
@@ -79,7 +79,7 @@ protected String getMyName() {
public static Resolved getResolved(
String template, Cache<String, Resolved> cache, Pattern pattern) {
- Resolved r = cache == null ? null : cache.get(template);
+ Resolved r = cache == null ? null : cache.getIfPresent(template);
Review Comment:
yes that would definitely be better... I forgot why I didn't do that as it crossed my mind but I think some _other_ updated files would take more changes than I wanted to do in-scope. I'll do this at least here in a minute
--
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: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] Replace ConcurrentLRUCache and Cache interface with Caffeine [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley merged PR #4516:
URL: https://github.com/apache/solr/pull/4516
--
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: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org
Re: [PR] Replace ConcurrentLRUCache and Cache interface with Caffeine [solr]
Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #4516:
URL: https://github.com/apache/solr/pull/4516#issuecomment-4663438386
Changelog or not is debatable. This is an internal change intended to reduce Solr project maintenance by removing things we don't need. I don't imagine a user will be impacted. Even though JavaBinCodec.StringCache is technically public... it's *very* internal. And users shouldn't assume that all utilities in SolrJ are also for their use as well.
--
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: issues-unsubscribe@solr.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org