-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add caching for getAvailabilityZones (#1658)
- Loading branch information
1 parent
469d6be
commit 0f53ec9
Showing
15 changed files
with
142 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
~ SPDX-FileCopyrightText: Huawei Inc. | ||
~ | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.eclipse.xpanse</groupId> | ||
<artifactId>modules</artifactId> | ||
<version>1.0.15-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<groupId>org.eclipse.xpanse.modules</groupId> | ||
<artifactId>cache</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.ben-manes.caffeine</groupId> | ||
<artifactId>caffeine</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-cache</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
40 changes: 40 additions & 0 deletions
40
modules/cache/src/main/java/org/eclipse/xpanse/modules/cache/RegionAzCacheConfig.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,40 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* SPDX-FileCopyrightText: Huawei Inc. | ||
* | ||
*/ | ||
|
||
package org.eclipse.xpanse.modules.cache; | ||
|
||
import com.github.benmanes.caffeine.cache.Caffeine; | ||
import java.util.concurrent.TimeUnit; | ||
import org.eclipse.xpanse.modules.cache.consts.CacheNames; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.cache.caffeine.CaffeineCacheManager; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
/** | ||
* Region AZ information cache configuration class. | ||
*/ | ||
@Configuration | ||
public class RegionAzCacheConfig { | ||
|
||
@Value("${region.azs.cache.expire.time.in.minutes:60}") | ||
private long duration; | ||
|
||
/** | ||
* Create the configured CaffeineCacheManager. | ||
* | ||
* @return CaffeineCacheManager | ||
*/ | ||
@Bean | ||
public CaffeineCacheManager caffeineCacheManager() { | ||
CaffeineCacheManager cacheManager = new CaffeineCacheManager( | ||
CacheNames.REGION_AZ_CACHE_NAME); | ||
cacheManager.setCaffeine(Caffeine.newBuilder() | ||
.expireAfterWrite(duration, TimeUnit.MINUTES)); | ||
return cacheManager; | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
modules/cache/src/main/java/org/eclipse/xpanse/modules/cache/consts/CacheNames.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,16 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* SPDX-FileCopyrightText: Huawei Inc. | ||
* | ||
*/ | ||
|
||
package org.eclipse.xpanse.modules.cache.consts; | ||
|
||
/** | ||
* Region az information cache constant class. | ||
*/ | ||
public class CacheNames { | ||
|
||
public static final String REGION_AZ_CACHE_NAME = "region_azs_cache"; | ||
|
||
} |
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
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
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
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
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
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