@@ -14,15 +14,16 @@ To integrate this Git repository into your project, simply add the maven depende
1414<dependency >
1515 <groupId >com.dasburo</groupId >
1616 <artifactId >spring-cache-dynamodb</artifactId >
17- <version >0.9.6 </version >
17+ <version >2.0.0 </version >
1818</dependency >
1919```
20+ This release is using the AWS Java SDK v2.x. If you must use v1.x, please use a version prior to 2.0.0 of this library.
2021
2122## Usage
2223
2324### Quick start
2425
25- There is an autoconfiguration class that will setup a simple key-value cache for you, provided you have specified the following properties.
26+ There is an autoconfiguration class that will set up a simple key-value cache for you, provided you have specified the following properties.
2627
2728#### Properties
2829
@@ -58,28 +59,29 @@ To customize the creation of a cache manager, create a Java Bean in a [configura
5859
5960` ` ` java
6061@Bean
61- public AWSCredentials amazonAWSCredentials () {
62- return new BasicAWSCredentials (amazonAWSAccessKey, amazonAWSSecretKey);
62+ public AwsCredentials awsCredentials () {
63+ return AwsBasicCredentials.create (amazonAWSAccessKey, amazonAWSSecretKey);
6364}
6465
6566@Bean
66- public AWSCredentialsProvider amazonAWSCredentialsProvider(AWSCredentials amazonAWSCredentials ) {
67- return new AWSStaticCredentialsProvider(amazonAWSCredentials );
67+ public AwsCredentialsProvider awsCredentialsProvider(AwsCredentials awsCredentials ) {
68+ return StaticCredentialsProvider.create(awsCredentials );
6869}
6970
7071@Bean
71- public AmazonDynamoDB amazonDynamoDB(AWSCredentialsProvider amazonAWSCredentialsProvider) {
72- return AmazonDynamoDBClientBuilder.standard()
73- .withCredentials(amazonAWSCredentialsProvider)
74- .withRegion(Regions.EU_CENTRAL_1).build();
72+ public DynamoDbClient amazonDynamoDB(AwsCredentialsProvider awsCredentialsProvider) {
73+ return DynamoDbClient.builder()
74+ .credentialsProvider(awsCredentialsProvider)
75+ .region(Region.of(amazonAWSRegion))
76+ .build();
7577}
7678
7779@Bean
78- public CacheManager cacheManager(AmazonDynamoDB amazonDynamoDB ) {
80+ public CacheManager cacheManager(DynamoDbClient ddb ) {
7981 List<DynamoCacheBuilder> cacheBuilders = new ArrayList<>();
80- cacheBuilders.add(DynamoCacheBuilder.newInstance("myCache", amazonDynamoDB )
81- .withTTL(Duration.ofSeconds(600 )));
82-
82+ cacheBuilders.add(DynamoCacheBuilder.newInstance(cacheName, ddb )
83+ .withTTL(Duration.ofSeconds(cacheTtl )));
84+
8385 return new DynamoCacheManager(cacheBuilders);
8486}
8587```
0 commit comments