synchronized void save() { Long lastKey = this.lastSyncKey; Set<Entry<Long, RedoLogValue>> entrySet = lastKey == null ? skipListMap.entrySet() : skipListMap.tailMap(lastKey, false).entrySet(); if (!entrySet.isEmpty()) { WriteBuffer buff = WriteBufferPool.poll(); try { for (Entry<Long, RedoLogValue> e : entrySet) { lastKey = e.getKey(); keyType.write(buff, lastKey); valueType.write(buff, e.getValue()); } int chunkLength = buff.position(); if (chunkLength > 0) { buff.limit(chunkLength); buff.position(0); fileStorage.writeFully(pos, buff.getBuffer()); pos += chunkLength; fileStorage.sync(); } this.lastSyncKey = lastKey; } finally { WriteBufferPool.offer(buff); } } }