Package com.enhancedechest.storage
Class AutosaveService
java.lang.Object
com.enhancedechest.storage.AutosaveService
Write-back scheduling for the lazy cache: an async repeating timer at the configured
database.autosave-interval (default 3m) that calls CachedStorage.flush() and then
CachedStorage.evictIdle() (releasing owners who are offline and fully flushed), plus the
per-player write-back a few seconds after a quit (flushQuitterLater(java.util.UUID)). The flush itself
snapshots dirty rows under the cache lock and performs the JDBC writes off it, so an autosave never
blocks gameplay. The final save of everything happens in CachedStorage.close() at shutdown,
independent of this timer.
Failures are logged and reported to telemetry, never thrown — the failed rows stay dirty inside
the cache and are retried on the next tick. Interval changes apply on /ee reload via
reschedule(long).
-
Constructor Summary
ConstructorsConstructorDescriptionAutosaveService(CachedStorage storage, Scheduler scheduler, org.slf4j.Logger logger, Telemetry telemetry, long intervalMillis) -
Method Summary
Modifier and TypeMethodDescriptionvoidflushQuitterLater(UUID owner) Schedules one player's write-back + eviction shortly after they quit (seeQUIT_FLUSH_DELAY_MS).voidreschedule(long newIntervalMillis) Re-applies a possibly-changed interval after a/ee reload(restarts the timer).voidstart()Starts the repeating async autosave.voidstop()Cancels the repeating autosave.
-
Constructor Details
-
AutosaveService
public AutosaveService(CachedStorage storage, Scheduler scheduler, org.slf4j.Logger logger, Telemetry telemetry, long intervalMillis)
-
-
Method Details
-
start
public void start()Starts the repeating async autosave. -
reschedule
public void reschedule(long newIntervalMillis) Re-applies a possibly-changed interval after a/ee reload(restarts the timer). -
stop
public void stop()Cancels the repeating autosave. Safe to call even if never started. -
flushQuitterLater
Schedules one player's write-back + eviction shortly after they quit (seeQUIT_FLUSH_DELAY_MS). Runs async; failures are logged and stay dirty for the autosave.
-