forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not increment metrics on CaffeineCache#getIfPresent call
- Loading branch information
Showing
5 changed files
with
94 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
integration-tests/cache/src/main/java/io/quarkus/it/cache/GetIfPresentResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.quarkus.it.cache; | ||
|
||
import static java.util.concurrent.CompletableFuture.completedFuture; | ||
|
||
import java.util.concurrent.CompletionStage; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.PUT; | ||
import jakarta.ws.rs.Path; | ||
|
||
import org.jboss.resteasy.reactive.RestPath; | ||
|
||
import io.quarkus.cache.Cache; | ||
import io.quarkus.cache.CacheName; | ||
import io.quarkus.cache.CaffeineCache; | ||
|
||
@Path("/get-if-present") | ||
public class GetIfPresentResource { | ||
|
||
public static final String GET_IF_PRESENT_CACHE_NAME = "getIfPresentCache"; | ||
|
||
@CacheName(GET_IF_PRESENT_CACHE_NAME) | ||
Cache cache; | ||
|
||
@GET | ||
@Path("/{key}") | ||
public CompletionStage<String> getIfPresent(@RestPath String key) { | ||
return cache.as(CaffeineCache.class).getIfPresent(key); | ||
} | ||
|
||
@PUT | ||
@Path("/{key}") | ||
public void put(@RestPath String key, String value) { | ||
cache.as(CaffeineCache.class).put(key, completedFuture(value)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters