private void updateTtl(Record record, long ttl) { if (ttl > 0) { mapService.scheduleTtlEviction(name, record, ttl); } else if (ttl == 0) { mapContainer.getTtlEvictionScheduler().cancel(record.getKey()); } }
public Record createRecord( String name, Data dataKey, Object value, long ttl, boolean shouldSchedule) { MapContainer mapContainer = getMapContainer(name); Record record = mapContainer.getRecordFactory().newRecord(dataKey, value); if (shouldSchedule) { // if ttl is 0 then no eviction. if ttl is -1 then default configured eviction is applied if (ttl < 0 && mapContainer.getMapConfig().getTimeToLiveSeconds() > 0) { scheduleTtlEviction( name, record, mapContainer.getMapConfig().getTimeToLiveSeconds() * 1000); } else if (ttl > 0) { scheduleTtlEviction(name, record, ttl); } if (mapContainer.getMapConfig().getMaxIdleSeconds() > 0) { scheduleIdleEviction(name, dataKey, mapContainer.getMapConfig().getMaxIdleSeconds() * 1000); } } return record; }
public void applyRecordInfo(Record record, String mapName, RecordInfo replicationInfo) { record.setStatistics(replicationInfo.getStatistics()); record.setVersion(replicationInfo.getVersion()); if (replicationInfo.getIdleDelayMillis() >= 0) { scheduleIdleEviction(mapName, record.getKey(), replicationInfo.getIdleDelayMillis()); } if (replicationInfo.getTtlDelayMillis() >= 0) { scheduleTtlEviction(mapName, record, replicationInfo.getTtlDelayMillis()); } if (replicationInfo.getMapStoreWriteDelayMillis() >= 0) { scheduleMapStoreWrite( mapName, record.getKey(), record.getValue(), replicationInfo.getMapStoreWriteDelayMillis()); } if (replicationInfo.getMapStoreDeleteDelayMillis() >= 0) { scheduleMapStoreDelete( mapName, record.getKey(), replicationInfo.getMapStoreDeleteDelayMillis()); } }