public boolean set(Data key, Object value, long ttl) {
checkIfLoaded();
final long now = getNow();
markRecordStoreExpirable(ttl);
Record record = getRecordOrNull(key, now, false);
boolean newRecord = false;
if (record == null) {
value = mapServiceContext.interceptPut(name, null, value);
value = mapDataStore.add(key, value, now);
record = createRecord(key, value, ttl, now);
records.put(key, record);
updateSizeEstimator(calculateRecordHeapCost(record));
newRecord = true;
} else {
value = mapServiceContext.interceptPut(name, record.getValue(), value);
value = mapDataStore.add(key, value, now);
onStore(record);
// if key exists before, first reduce size
updateSizeEstimator(-calculateRecordHeapCost(record));
setRecordValue(record, value, now);