Skip to content
Closed
Show file tree
Hide file tree
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 @@ -115,6 +115,12 @@ public void execute(Tuple input) {
throw new IllegalArgumentException("Cannot process such data type: " + dataType);
}

long ttlMS = storeMapper.getTTLFromTuple(input);

if (ttlMS >= 0) {
jedisCommand.pexpire(key, ttlMS);
}

collector.ack(input);
} catch (Exception e) {
this.collector.reportError(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,17 @@
*/
package org.apache.storm.redis.common.mapper;

import org.apache.storm.tuple.ITuple;

/**
* RedisStoreMapper is for defining spec. which is used for storing value to Redis.
*/
public interface RedisStoreMapper extends TupleMapper, RedisMapper {
/**
* Extracts time to live from tuple.
*
* @param tuple
* @return time to live MS
*/
public long getTTLFromTuple(ITuple tuple);
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,10 @@ public String getKeyFromTuple(ITuple tuple) {
public String getValueFromTuple(ITuple tuple) {
return tuple.getStringByField("count");
}

@Override
public long getTTLFromTuple(ITuple tuple) {
return -1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ public String getKeyFromTuple(ITuple tuple) {
public String getValueFromTuple(ITuple tuple) {
return tuple.getInteger(1).toString();
}

@Override
public long getTTLFromTuple(ITuple tuple) {
return -1;
}
}