Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for com.github.ben-manes.caffeine:caffeine:2.9.3 #388

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"reflect-config.json"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
[
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BBHeader$ReadAndWriteCounterRef"},
"name":"com.github.benmanes.caffeine.cache.BBHeader$ReadAndWriteCounterRef",
"fields":[{"name":"writeCounter"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BBHeader$ReadCounterRef"},
"name":"com.github.benmanes.caffeine.cache.BBHeader$ReadCounterRef",
"fields":[{"name":"readCounter"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BLCHeader$DrainStatusRef"},
"name":"com.github.benmanes.caffeine.cache.BLCHeader$DrainStatusRef",
"fields":[{"name":"drainStatus"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue"},
"name":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueColdProducerFields",
"fields":[{"name":"producerLimit"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue"},
"name":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueConsumerFields",
"fields":[{"name":"consumerIndex"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue"},
"name":"com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueueProducerFields",
"fields":[{"name":"producerIndex"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.Caffeine"},
"name":"com.github.benmanes.caffeine.cache.CacheLoader",
"methods":[{"name":"asyncLoadAll","parameterTypes":["java.lang.Iterable","java.util.concurrent.Executor"] }, {"name":"loadAll","parameterTypes":["java.lang.Iterable"] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.LocalLoadingCache"},
"name":"com.github.benmanes.caffeine.cache.CacheLoader",
"methods":[{"name":"loadAll","parameterTypes":["java.lang.Iterable"] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.FW"},
"name":"com.github.benmanes.caffeine.cache.FW",
"fields":[{"name":"value"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.WI"},
"name":"com.github.benmanes.caffeine.cache.FW",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.NodeFactory"},
"name":"com.github.benmanes.caffeine.cache.PD",
"fields":[{"name":"value"}],
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.PS"},
"name":"com.github.benmanes.caffeine.cache.PS",
"fields":[{"name":"key"}, {"name":"value"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.PSA"},
"name":"com.github.benmanes.caffeine.cache.PSA",
"fields":[{"name":"accessTime"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.SSA"},
"name":"com.github.benmanes.caffeine.cache.PSA",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.SSSMS"},
"name":"com.github.benmanes.caffeine.cache.PSMS",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.SSMW"},
"name":"com.github.benmanes.caffeine.cache.PSMW",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.PSR"},
"name":"com.github.benmanes.caffeine.cache.PSR",
"fields":[{"name":"writeTime"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.SSR"},
"name":"com.github.benmanes.caffeine.cache.PSR",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.PSW"},
"name":"com.github.benmanes.caffeine.cache.PSW",
"fields":[{"name":"writeTime"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.SSA"},
"name":"com.github.benmanes.caffeine.cache.PSW",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.SSW"},
"name":"com.github.benmanes.caffeine.cache.PSW",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.SSSMW"},
"name":"com.github.benmanes.caffeine.cache.PSWMW",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.NodeFactory"},
"name":"com.github.benmanes.caffeine.cache.PW",
"fields":[{"name":"value"}],
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache"},
"name":"com.github.benmanes.caffeine.cache.SI",
"methods":[{"name":"<init>","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache"},
"name":"com.github.benmanes.caffeine.cache.SSA",
"methods":[{"name":"<init>","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache"},
"name":"com.github.benmanes.caffeine.cache.SSMS",
"methods":[{"name":"<init>","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.LocalCacheFactory"},
"name":"com.github.benmanes.caffeine.cache.SSMSW",
"methods":[{"name":"<init>","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache"},
"name":"com.github.benmanes.caffeine.cache.SSMW",
"methods":[{"name":"<init>","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache"},
"name":"com.github.benmanes.caffeine.cache.SSR",
"methods":[{"name":"<init>","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalManualCache"},
"name":"com.github.benmanes.caffeine.cache.SSSMS",
"methods":[{"name":"<init>","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache"},
"name":"com.github.benmanes.caffeine.cache.SSSMWW",
"methods":[{"name":"<init>","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache"},
"name":"com.github.benmanes.caffeine.cache.SSW",
linghengqian marked this conversation as resolved.
Show resolved Hide resolved
"methods":[{"name":"<init>","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.StripedBuffer"},
"name":"com.github.benmanes.caffeine.cache.StripedBuffer",
"fields":[{"name":"tableBusy"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.BoundedLocalCache$BoundedLocalLoadingCache"},
"name":"com.github.benmanes.caffeine.cache.WI",
"methods":[{"name":"<init>","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.StripedBuffer"},
"name":"java.lang.Thread",
"fields":[{"name":"threadLocalRandomProbe"}]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.SSMSR"},
"name":"com.github.benmanes.caffeine.cache.PSRMS",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.NodeFactory"},
"name":"com.github.benmanes.caffeine.cache.PSWMS",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"condition":{"typeReachable":"com.github.benmanes.caffeine.cache.NodeFactory"},
"name":"com.github.benmanes.caffeine.cache.SSMWW",
"methods":[{"name":"<init>","parameterTypes":["com.github.benmanes.caffeine.cache.Caffeine","com.github.benmanes.caffeine.cache.CacheLoader","boolean"] }]
}
]
7 changes: 7 additions & 0 deletions metadata/com.github.ben-manes.caffeine/caffeine/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,12 @@
"tested-versions": [
"3.1.2"
]
},
{
"metadata-version": "2.9.3",
"module": "com.github.ben-manes.caffeine:caffeine",
"tested-versions": [
"2.9.3"
]
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
gradlew.bat
gradlew
gradle/
build/
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright and related rights waived via CC0
*
* You should have received a copy of the CC0 legalcode along with this
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/

plugins {
id "org.graalvm.internal.tck"
}

String libraryVersion = tck.testedLibraryVersion.get()

dependencies {
testImplementation "com.github.ben-manes.caffeine:caffeine:$libraryVersion"
testImplementation 'org.assertj:assertj-core:3.22.0'
testImplementation 'org.awaitility:awaitility:4.2.0'
testImplementation 'com.google.guava:guava-testlib:32.1.2-jre'
}

graalvmNative {
agent {
defaultMode = "conditional"
modes {
conditional {
userCodeFilterPath = "user-code-filter.json"
}
}
metadataCopy {
dnestoro marked this conversation as resolved.
Show resolved Hide resolved
mergeWithExisting = true
inputTaskNames.add("test")
outputDirectories.add("src/test/resources/META-INF/native-image/com.github.ben-manes.caffeine/caffeine")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
library.version = 2.9.3
metadata.dir = com.github.ben-manes.caffeine/caffeine/2.9.3/
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pluginManagement {
def tckPath = Objects.requireNonNullElse(
System.getenv("GVM_TCK_TCKDIR"),
"../../../../tck-build-logic"
)
includeBuild(tckPath)
}

plugins {
id "org.graalvm.internal.tck-settings" version "1.0.0-SNAPSHOT"
}

rootProject.name = 'com.github.ben-manes.caffeine.caffeine_tests'
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright and related rights waived via CC0
*
* You should have received a copy of the CC0 legalcode along with this
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
package com_github_ben_manes_caffeine.caffeine;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.CaffeineSpec;
import com.github.benmanes.caffeine.cache.LoadingCache;
import com.github.benmanes.caffeine.cache.Scheduler;
import com.github.benmanes.caffeine.cache.stats.CacheStats;
import com.google.common.testing.FakeTicker;
import org.junit.jupiter.api.Test;

import java.lang.ref.Cleaner;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

public class CaffeineTest {
@Test
void testRefresh() {
TestRefreshLoader testRefreshLoader = new TestRefreshLoader();
LoadingCache<String, CompletableFuture<String>> cache = Caffeine.newBuilder()
.refreshAfterWrite(Duration.ofMillis(100))
.build(testRefreshLoader::load);
cache.get("Hello");
CompletableFuture<String> firstValue = cache.getIfPresent("Hello");
assertThat(firstValue).isNotNull();
assertEquals("World", firstValue.join());
testRefreshLoader.setFlag(true);
cache.refresh("Hello");
await().atMost(Duration.ofSeconds(5)).untilAsserted(() -> {
CompletableFuture<String> secondValue = cache.getIfPresent("Hello");
assertThat(secondValue).isNotNull();
assertEquals("Universe", secondValue.join());
});
}

@Test
void testStatistics() {
Cache<String, String> graphs = Caffeine.newBuilder().maximumSize(10_000).recordStats().build();
linghengqian marked this conversation as resolved.
Show resolved Hide resolved
graphs.put("Hello", "World");
assertThat(graphs.getIfPresent("Hello")).isEqualTo("World");
CacheStats cacheStats = graphs.stats();
assertThat(cacheStats.hitCount()).isEqualTo(1);
assertThat(cacheStats.missCount()).isEqualTo(0);
assertThat(cacheStats.evictionCount()).isEqualTo(0);
}

@Test
void testSpecification() {
CaffeineSpec spec = CaffeineSpec.parse("maximumWeight=1000, expireAfterWrite=10m");
LoadingCache<String, String> graphs = Caffeine.from(spec).weigher((String key, String graph) -> graph.length())
.build(key -> key.equals("Hello") ? "World" : "Universe");
assertThat(graphs.get("Hello")).isEqualTo("World");
}

@Test
void testCleanup() {
FakeTicker ticker = new FakeTicker();
LoadingCache<String, String> firstGraphs = Caffeine.newBuilder()
.scheduler(Scheduler.systemScheduler())
.expireAfterWrite(10, TimeUnit.MINUTES)
.ticker(ticker::read)
.build(key -> key.equals("Hello") ? "World" : "Universe");
firstGraphs.put("Hello", "World");
assertNotEquals(0, firstGraphs.estimatedSize());
assertThat(firstGraphs.getIfPresent("Hello")).isEqualTo("World");
linghengqian marked this conversation as resolved.
Show resolved Hide resolved
ticker.advance(10, TimeUnit.MINUTES);
firstGraphs.cleanUp();
assertEquals(0, firstGraphs.estimatedSize());
Cache<String, String> secondGraphs = Caffeine.newBuilder().weakValues().build();
Cleaner cleaner = Cleaner.create();
cleaner.register("World", secondGraphs::cleanUp);
secondGraphs.put("Hello", "World");
assertThat(secondGraphs.getIfPresent("Hello")).isEqualTo("World");
}

@Test
void testTesting() {
FakeTicker ticker = new FakeTicker();
Cache<String, String> cache = Caffeine.newBuilder()
.expireAfterWrite(10, TimeUnit.MINUTES)
.executor(Runnable::run)
.ticker(ticker::read)
.maximumSize(10)
.build();
cache.put("Hello", "World");
ticker.advance(30, TimeUnit.MINUTES);
assertThat(cache.getIfPresent("Hello")).isNull();
}
}
Loading
Loading