-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'grad-release' into main
- Loading branch information
Showing
55 changed files
with
2,040 additions
and
80 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
47 changes: 47 additions & 0 deletions
47
api/src/main/java/ca/bc/gov/educ/api/trax/cache/CacheInitializer.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,47 @@ | ||
package ca.bc.gov.educ.api.trax.cache; | ||
|
||
import ca.bc.gov.educ.api.trax.service.institute.CodeService; | ||
import ca.bc.gov.educ.api.trax.service.institute.DistrictService; | ||
import ca.bc.gov.educ.api.trax.service.institute.SchoolService; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Profile("!test") | ||
@Slf4j | ||
@Component | ||
public class CacheInitializer implements CommandLineRunner { | ||
|
||
@Autowired | ||
SchoolService schoolService; | ||
@Autowired | ||
DistrictService districtService; | ||
@Autowired | ||
CodeService codeService; | ||
|
||
@Override | ||
public void run(String... args) { | ||
schoolService.loadSchoolsIntoRedisCache( | ||
schoolService.getSchoolsFromInstituteApi() | ||
); | ||
log.info("Institutes loaded into Redis"); | ||
|
||
districtService.loadDistrictsIntoRedisCache( | ||
districtService.getDistrictsFromInstituteApi() | ||
); | ||
log.info("Districts loaded into Redis"); | ||
|
||
codeService.loadSchoolCategoryCodesIntoRedisCache( | ||
codeService.getSchoolCategoryCodesFromInstituteApi() | ||
); | ||
log.info("School Category Codes loaded into Redis"); | ||
codeService.loadSchoolFundingGroupCodesIntoRedisCache( | ||
codeService.getSchoolFundingGroupCodesFromInstituteApi() | ||
); | ||
log.info("School Funding Group Codes loaded into Redis"); | ||
|
||
log.info("Redis Cache initialized!"); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
api/src/main/java/ca/bc/gov/educ/api/trax/config/RedisConfig.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,41 @@ | ||
package ca.bc.gov.educ.api.trax.config; | ||
|
||
import ca.bc.gov.educ.api.trax.util.EducGradTraxApiConstants; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration; | ||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; | ||
import org.springframework.data.redis.serializer.GenericToStringSerializer; | ||
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
|
||
@Configuration | ||
@EnableRedisRepositories("ca.bc.gov.educ.api.trax.repository.redis") | ||
public class RedisConfig { | ||
@Autowired | ||
private EducGradTraxApiConstants constants; | ||
@Bean | ||
public JedisConnectionFactory jedisConnectionFactory() { | ||
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(); | ||
redisStandaloneConfiguration.setHostName(constants.getRedisUrl()); | ||
redisStandaloneConfiguration.setPort(Integer.parseInt(constants.getRedisPort())); | ||
return new JedisConnectionFactory(redisStandaloneConfiguration); | ||
} | ||
|
||
@Bean | ||
public RedisTemplate<String, Object> redisTemplate() { | ||
final RedisTemplate<String, Object> template = new RedisTemplate<>(); | ||
template.setConnectionFactory(jedisConnectionFactory()); | ||
template.setKeySerializer(new StringRedisSerializer()); | ||
template.setValueSerializer(new GenericToStringSerializer<>(Object.class)); | ||
template.setHashKeySerializer(new JdkSerializationRedisSerializer()); | ||
template.setHashValueSerializer(new JdkSerializationRedisSerializer()); | ||
template.setEnableTransactionSupport(true); | ||
template.afterPropertiesSet(); | ||
|
||
return template; | ||
} | ||
} |
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.