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

[ISSUE #7487] Add generics for the CacheBuilder. #7490

Merged
merged 1 commit into from
Apr 27, 2022
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
Expand Up @@ -40,7 +40,7 @@ public class Limiter {
private static final Cache<String, RateLimiter> CACHE;

static {
CACHE = CacheBuilder.builder()
CACHE = CacheBuilder.<String, RateLimiter>builder()
.expireNanos(1, TimeUnit.MINUTES)
.initializeCapacity(CAPACITY_SIZE)
.sync(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class CacheBuilder<K, V> {
private static final int DEFAULT_EXPIRE_NANOS = -1;

private long expireNanos = DEFAULT_EXPIRE_NANOS;

private int maximumSize = DEFAULT_MAXIMUMSIZE;

private int initializeCapacity = DEFAULT_INITIALIZE_CAPACITY;
Expand All @@ -48,14 +48,14 @@ public class CacheBuilder<K, V> {

private boolean lru = false;

public static CacheBuilder builder() {
return new CacheBuilder();
public static <K, V> CacheBuilder<K, V> builder() {
return new CacheBuilder<>();
}

/**
* Set expiration time.
*/
public CacheBuilder expireNanos(long duration, TimeUnit unit) {
public CacheBuilder<K, V> expireNanos(long duration, TimeUnit unit) {
checkExpireNanos(duration, unit);
this.expireNanos = unit.toNanos(duration);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class StringPool {
private static final Cache<String, String> GROUP_KEY_CACHE;

static {
GROUP_KEY_CACHE = CacheBuilder.builder().maximumSize(5000000)
GROUP_KEY_CACHE = CacheBuilder.<String, String>builder().maximumSize(5000000)
.expireNanos(180, TimeUnit.SECONDS)
.lru(true)
.build();
Expand Down