Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W-13497368 #534

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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