Giriş
Şu satırı dahil ederiz
import com.hazelcast.map.ExtendedMapEntry;
Örnek
Şöyle yaparız
class IncrementWithOptionalTtl implements EntryProcessor<Integer, Integer, Void> { private final long ttlSeconds; public IncrementWithOptionalTtl(long ttlSeconds) { this.ttlSeconds = ttlSeconds; } @Override public Void process(Map.Entry<Integer, Integer> e) { ExtendedMapEntry<Integer, Integer> entry = (ExtendedMapEntry<Integer, Integer>) e; int newValue = entry.getValue() + 1; if (ttlSeconds > 0) { entry.setValue(newValue, ttlSeconds, TimeUnit.SECONDS); } else { entry.setValue(newValue); } return null; } }
Örnek
Şöyle yaparız
public Object process(Entry entry) { Object oldValue = entry.getValue(); ExtendedMapEntry extendedMapEntry = (com.hazelcast.map.ExtendedMapEntry) entry; extendedMapEntry.setValue(oldValue, 30, TimeUnit.SECONDS); return oldValue; }
Hiç yorum yok:
Yorum Gönder