Skip to content

Commit

Permalink
Merge pull request #534 from salesforce/or-koren-patch-2
Browse files Browse the repository at this point in the history
W-13497368
  • Loading branch information
or-koren authored Jun 1, 2023
2 parents fda066f + 1879d8d commit 2e6f982
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class RedisCacheHandler extends AbstractCacheHandler {
private JedisLock lock;
private final RedisService redisService;
private final int redisTtlInSeconds;

private int orphanRedisTTLRedisTTLInSeconds;
private int cacheRedisTTLRedisTTLInSeconds;


RedisCacheHandler(RedisService redisService, int cacheRedisTtlInSeconds) {
Expand All @@ -31,6 +34,9 @@ public class RedisCacheHandler extends AbstractCacheHandler {
}
this.redisService = redisService;
this.redisTtlInSeconds = cacheRedisTtlInSeconds;
orphanRedisTTLRedisTTLInSeconds = System.getenv("ORPHANS_REDIS_TTL_SECONDS") != null ? Integer.parseInt(System.getenv("ORPHANS_REDIS_TTL_SECONDS")) : cacheRedisTtlInSeconds;
cacheRedisTTLRedisTTLInSeconds = System.getenv("CACHE_REDIS_TTL_SECONDS") != null ? Integer.parseInt(System.getenv("CACHE_REDIS_TTL_SECONDS")) : cacheRedisTtlInSeconds;
LOG.info("Initializing Timbermill Redis Cache with orphanRedisTTLRedisTTLInSeconds {} seconds and cacheRedisTTLRedisTTLInSeconds {}", orphanRedisTTLRedisTTLInSeconds, cacheRedisTTLRedisTTLInSeconds);
}

@Override
Expand All @@ -53,8 +59,8 @@ public void pushToOrphanCache(Map<String, List<String>> orphansMap) {
String orphanCacheKey = ORPHAN_PREFIX + entry.getKey();
newOrphansMap.put(orphanCacheKey, entry.getValue());
}
final int ttlToUse = System.getenv("ORPHANS_REDIS_TTL_SECONDS") != null ? Integer.parseInt(System.getenv("ORPHANS_REDIS_TTL_SECONDS")) : redisTtlInSeconds;
if (!redisService.pushToRedis(newOrphansMap, ttlToUse)){

if (!redisService.pushToRedis(newOrphansMap, orphanRedisTTLRedisTTLInSeconds)){
LOG.error("Failed to push some ids to Redis orphans cache.");
KamonConstants.ORPHAN_CACHE_FAILED_COUNTER.withoutTags().increment();
}
Expand All @@ -67,8 +73,7 @@ public Map<String, LocalTask> getFromTasksCache(Collection<String> idsList) {

@Override
public void pushToTasksCache(Map<String, LocalTask> idsToMap) {
final int ttlToUse = System.getenv("CACHE_REDIS_TTL_SECONDS") != null ? Integer.parseInt(System.getenv("CACHE_REDIS_TTL_SECONDS")) : redisTtlInSeconds;
boolean allPushed = redisService.pushToRedis(idsToMap, ttlToUse);
boolean allPushed = redisService.pushToRedis(idsToMap, cacheRedisTTLRedisTTLInSeconds);
if (!allPushed){
LOG.error("Failed to push some ids to Redis tasks cache.");
}
Expand Down

0 comments on commit 2e6f982

Please sign in to comment.