/**
* Returns the ttl (in order of preference) feed producer ttl (if exists)
* wantedTtl (if exists) defaultTtl (if exists).
*/
public long getTtl(ChannelIF channel, long ttlInMs) {
ChannelUpdatePeriod updatePeriod = channel.getUpdatePeriod();
int updateFrequency = channel.getUpdateFrequency();
if (updatePeriod == null) {
if (ttlInMs > MINIMAL_TTL)
return ttlInMs;
return this.defaultTtl;
}
if (updateFrequency < 0) {
updateFrequency = 1;
}
long timeToExpire = updatePeriod.getMsInPeriod() / updateFrequency;
if (ttlInMs > timeToExpire) {
return ttlInMs;
}
return timeToExpire;