Vixen
c7401864
csharp
public sealed class CheckpointPolicy

When a character's counters are written down.

Read the guide page for this →

Remarks

Counters go in the profile and assets go in the ledger — see LedgerBridge for the other half. The difference decides the cadence: a quantity of an asset can be duplicated, so every movement of one is a row; a level cannot, because writing 42 twice leaves you at 42. So a level is written on a cadence and a crash loses at most one interval of experience.

⚠ That loss is the correct trade rather than a compromise. Making a counter durable per kill puts a database round trip on the combat path, which ADR-016 forbids outright — "a frame that awaits one has a p99 measured in milliseconds and a p99.9 measured in seconds".

⚠ A failed write leaves it dirty and does not restart the clock. Clearing the flag loses the interval for good; restarting the clock means a store that is briefly unhappy is retried a whole cadence later, which turns a five-second outage into five minutes of lost progress.

⚠ Transfer and logout write only when there is something to write. "Always on transfer" reads as unconditional and should not be: a character nobody changed has the same bytes stored, and a round trip to write them is a round trip inside the overlap window L2 spends on loading a map.

Fields and properties (5)

  • public TimeSpan Cadence

    How long between writes.

  • public bool IsDirty

    Whether anything has changed since the last successful write.

  • public DateTimeOffset Written

    When the last successful write happened.

  • public int Failures

    How many writes have failed in a row.

  • public int Writes

    How many have succeeded.

Methods (7)

  • public CheckpointPolicy(TimeSpan cadence)

    Makes one.

  • public void Touch()

    Says something changed.

  • public void Force(CheckpointReason reason)

    Says a write must happen at the next opportunity.

  • public bool Due(DateTimeOffset now, out CheckpointReason reason)

    Whether to write now.

  • public void Wrote(DateTimeOffset now)

    Says a write landed.

  • public void Failed()

    Says a write did not land.

  • public void Loaded(DateTimeOffset now)

    Starts the clock without writing. What loading a character does.

Used by (6)

  • ExplorationSectionVixen.Live.Gameplay
  • PlayerProfileTestsVixen.Live.Gameplay.Tests
  • ProfilePityStoreVixen.Live.Gameplay
  • ProgressionSectionVixen.Live.Gameplay
  • QuestSectionVixen.Live.Gameplay
  • WardrobeSectionVixen.Live.Gameplay