com.redis.spring.batch.writer.operation.ExpireAt Maven / Gradle / Ivy
package com.redis.spring.batch.writer.operation;
import java.util.List;
import java.util.function.ToLongFunction;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.api.async.BaseRedisAsyncCommands;
import io.lettuce.core.api.async.RedisKeyAsyncCommands;
public class ExpireAt extends AbstractOperation {
private ToLongFunction epoch;
public void setEpoch(ToLongFunction function) {
this.epoch = function;
}
@SuppressWarnings("unchecked")
@Override
public void execute(BaseRedisAsyncCommands commands, T item, List> futures) {
long millis = epoch.applyAsLong(item);
if (millis > 0) {
futures.add(((RedisKeyAsyncCommands) commands).pexpireat(key(item), millis));
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy