-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from mosip/develop
[INJICERT-37] move develop changes to release branch
- Loading branch information
Showing
55 changed files
with
1,382 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ on: | |
- develop | ||
- MOSIP* | ||
- release* | ||
- INJICERT-13 | ||
- INJICERT-* | ||
|
||
jobs: | ||
build-maven-inji-certify: | ||
|
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
40 changes: 40 additions & 0 deletions
40
certify-core/src/main/java/io/mosip/certify/core/config/RedisCacheConfig.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 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
package io.mosip.certify.core.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.cache.RedisCacheManagerBuilderCustomizer; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.cache.RedisCacheConfiguration; | ||
|
||
import java.time.Duration; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
|
||
@ConditionalOnProperty(value = "spring.cache.type", havingValue = "redis") | ||
@Configuration | ||
public class RedisCacheConfig { | ||
|
||
@Value("#{${mosip.certify.cache.expire-in-seconds}}") | ||
private Map<String, Integer> cacheNamesWithTTLMap; | ||
|
||
@Bean | ||
public RedisCacheManagerBuilderCustomizer redisCacheManagerBuilderCustomizer() { | ||
return (builder) -> { | ||
Map<String, RedisCacheConfiguration> configurationMap = new HashMap<>(); | ||
cacheNamesWithTTLMap.forEach((cacheName, ttl) -> { | ||
configurationMap.put(cacheName, RedisCacheConfiguration | ||
.defaultCacheConfig() | ||
.disableCachingNullValues() | ||
.entryTtl(Duration.ofSeconds(ttl))); | ||
}); | ||
builder.withInitialCacheConfigurations(configurationMap); | ||
}; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
certify-core/src/main/java/io/mosip/certify/core/config/SimpleCacheConfig.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,58 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
package io.mosip.certify.core.config; | ||
|
||
import com.google.common.cache.CacheBuilder; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.cache.Cache; | ||
import org.springframework.cache.CacheManager; | ||
import org.springframework.cache.annotation.CachingConfigurerSupport; | ||
import org.springframework.cache.concurrent.ConcurrentMapCache; | ||
import org.springframework.cache.support.SimpleCacheManager; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@ConditionalOnProperty(value = "spring.cache.type", havingValue = "simple") | ||
@Configuration | ||
public class SimpleCacheConfig extends CachingConfigurerSupport { | ||
|
||
@Value("${mosip.certify.cache.names}") | ||
private List<String> cacheNames; | ||
|
||
@Value("#{${mosip.certify.cache.size}}") | ||
private Map<String, Integer> cacheMaxSize; | ||
|
||
@Value("#{${mosip.certify.cache.expire-in-seconds}}") | ||
private Map<String, Integer> cacheExpireInSeconds; | ||
|
||
|
||
@Bean | ||
@Override | ||
public CacheManager cacheManager() { | ||
SimpleCacheManager cacheManager = new SimpleCacheManager(); | ||
List<Cache> caches = new ArrayList<>(); | ||
for(String name : cacheNames) { | ||
caches.add(buildMapCache(name)); | ||
} | ||
cacheManager.setCaches(caches); | ||
return cacheManager; | ||
} | ||
|
||
private ConcurrentMapCache buildMapCache(String name) { | ||
return new ConcurrentMapCache(name, | ||
CacheBuilder.newBuilder() | ||
.expireAfterWrite(cacheExpireInSeconds.getOrDefault(name, 60), TimeUnit.SECONDS) | ||
.maximumSize(cacheMaxSize.getOrDefault(name, 100)) | ||
.build() | ||
.asMap(), true); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,6 @@ | |
public class AuditDTO { | ||
|
||
String transactionId; | ||
String clientId; | ||
String idType; | ||
} |
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
Oops, something went wrong.