Created
November 26, 2019 12:07
-
-
Save jelinski/4b8c0e280f4aa74a7dcfea03f7115e9b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import com.github.benmanes.caffeine.cache.Caffeine; | |
import org.springframework.cache.caffeine.CaffeineCache; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import static java.time.Duration.ofHours; | |
import static java.time.Duration.ofMinutes; | |
@Configuration | |
public class CacheConfiguration { | |
@Bean | |
public CaffeineCache firstCaffeineCache() { | |
return new CaffeineCache("firstCache", | |
Caffeine.newBuilder() | |
.weakKeys() | |
.initialCapacity(100) | |
.maximumSize(512) | |
.expireAfterWrite(ofHours(12)) | |
.build()); | |
} | |
@Bean | |
public CaffeineCache secondCaffeineCache() { | |
return new CaffeineCache("secondCache", | |
Caffeine.newBuilder() | |
.maximumSize(128) | |
.expireAfterAccess(ofMinutes(30)) | |
.build()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment