Beispiel #1
0
        protected async Task SaveSnapshotAsync()
        {
            if (IsNew)
            {
                await StateStore.InsertAsync(this.State);

                IsNew = false;
            }
            else
            {
                await StateStore.UpdateAsync(this.State);
            }
        }
Beispiel #2
0
 protected virtual async Task SaveSnapshotAsync()
 {
     if (SnapshotType == SnapshotType.Master)
     {
         if (IsNew)
         {
             await StateStore.InsertAsync(this.State);
             storageVersion = this.State.Version;
             IsNew = false;
         }
         //如果版本号差超过设置则更新快照
         else if (this.State.Version - storageVersion >= SnapshotFrequency)
         {
             await StateStore.UpdateAsync(this.State);
             storageVersion = this.State.Version;
         }
     }
 }
Beispiel #3
0
 protected virtual async Task SaveSnapshotAsync()
 {
     if (SnapshotType == SnapshotType.Replica)
     {
         if (this.State.Version - storageVersion >= SnapshotFrequency)
         {
             await CustomSave();//自定义保存项
             if (IsNew)
             {
                 await StateStore.InsertAsync(this.State);
                 IsNew = false;
             }
             else
             {
                 await StateStore.UpdateAsync(this.State);
             }
             storageVersion = this.State.Version;
         }
     }
 }
Beispiel #4
0
        protected virtual async Task SaveSnapshotAsync(bool force = false)
        {
            if (SaveSnapshot)
            {
                if (force || (State.Version - StateStorageVersion >= SnapshotFrequency))
                {
                    await OnSaveSnapshot();//自定义保存项

                    if (IsNew)
                    {
                        await StateStore.InsertAsync(State);

                        IsNew = false;
                    }
                    else
                    {
                        await StateStore.UpdateAsync(State);
                    }
                    StateStorageVersion = State.Version;
                }
            }
        }