diff --git a/src/main/java/in/nosd/redis/dataadapters/RedisLookupDataAdapter.java b/src/main/java/in/nosd/redis/dataadapters/RedisLookupDataAdapter.java index 8a45928..dc2a7f5 100755 --- a/src/main/java/in/nosd/redis/dataadapters/RedisLookupDataAdapter.java +++ b/src/main/java/in/nosd/redis/dataadapters/RedisLookupDataAdapter.java @@ -156,17 +156,22 @@ public class RedisLookupDataAdapter extends LookupDataAdapter { @Override public LookupResult setValue(Object key, Object value) { + return setValueWithTtl(key, value, this.config.redisKeyTTL()); + } + + @Override + public LookupResult setValueWithTtl(Object key, Object value, Long ttlSec) { final Timer.Context time = redisSetRequestTimer.time(); try { - final String result = this.commands.setex(key.toString(), this.config.redisKeyTTL(), value.toString()); + final String result = this.commands.setex(key.toString(), ttlSec, value.toString()); if (!result.equals("OK")) { - LOG.warn("Redis SET key <{}> to value <{}> returned {}", key, value, result); + LOG.warn("Redis SETEX key <{}> to value <{}> with TTL <{}> returned {}", key, value, ttlSec, result); redisSetRequestErrors.mark(); return LookupResult.empty(); } return LookupResult.single(value.toString()); } catch (Exception e) { - LOG.error("Redis SET key <{}> to value <{}> returned an exception: {}", key, value, e); + LOG.error("Redis SETEX key <{}> to value <{}> with TTL <{}> returned an exception: {}", key, value, ttlSec, e); redisSetRequestErrors.mark(); return LookupResult.empty(); } finally {