Skip to content

Commit

Permalink
different redis connection for BM
Browse files Browse the repository at this point in the history
  • Loading branch information
saipradeep_ravipati committed Dec 5, 2023
1 parent 6d628ae commit 4d43f65
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/org/sunbird/cache/RedisCacheMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class RedisCacheMgr {
@Autowired
private JedisPool jedisPool;

@Autowired
private JedisPool jedisDataPopulationPool;

@Autowired
CbExtServerProperties cbExtServerProperties;

Expand Down Expand Up @@ -160,7 +163,7 @@ public List<Map<String, Object>> getAllKeysAndValues() {
return result;
}
public List<String> hget(String key,int index,String... fields) {
try (Jedis jedis = jedisPool.getResource()) {
try (Jedis jedis = jedisDataPopulationPool.getResource()) {
jedis.select(index);
return jedis.hmget(key,fields);
} catch (Exception e) {
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/org/sunbird/common/util/CbExtServerProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,28 @@ public class CbExtServerProperties {
@Value("${redis.port}")
private String redisPort;

public String getRedisDataHostName() {
return redisDataHostName;
}

public void setRedisDataHostName(String redisDataHostName) {
this.redisDataHostName = redisDataHostName;
}

public String getRedisDataPort() {
return redisDataPort;
}

public void setRedisDataPort(String redisDataPort) {
this.redisDataPort = redisDataPort;
}

@Value("${redis.data.host.name}")
private String redisDataHostName;

@Value("${redis.data.port}")
private String redisDataPort;

@Value("${redis.timeout}")
private String redisTimeout;

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/sunbird/core/config/RedisConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ public JedisPool jedisPool() {
return jedisPool;
}

@Bean
public JedisPool jedisDataPopulationPool() {
final JedisPoolConfig poolConfig = buildPoolConfig();
JedisPool jedisPool = new JedisPool(poolConfig, cbProperties.getRedisDataHostName(),
Integer.parseInt(cbProperties.getRedisDataPort()));
return jedisPool;
}
private JedisPoolConfig buildPoolConfig() {
final JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxIdle(128);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ redis.port=6379
#redis timeout value is in seconds
redis.timeout=84600

redis.data.host.name=127.0.0.1
redis.data.port=6379

#Assessment Feature values
assessment.host=http://assessment-service:9000/
assessment.hierarchy.read.path=questionset/v4/hierarchy/{identifier}?mode=edit
Expand Down

0 comments on commit 4d43f65

Please sign in to comment.