Skip to content

Commit

Permalink
[修复]1. 修复异步删除没有实现的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
AlianBlank committed Jul 4, 2024
1 parent 40eca08 commit 1e86355
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,13 @@ public async void Open(string url, string dbName)
/// <returns></returns>
public async Task<long> DeleteAsync<TState>(Expression<Func<TState, bool>> filter) where TState : ICacheState, new()
{
// var newFilter = Builders<TState>.Filter.Where(filter);
// var collectionName = typeof(TState).Name;
// var collection = CurrentDatabase.GetCollection<TState>(collectionName);
// state.DeleteTime = DateTime.UtcNow;
// state.IsDeleted = true;
// var result = await collection.ReplaceOneAsync(filter, state, ReplaceOptions);
// return result.ModifiedCount;
return -1;
var collection = GetCollection<TState>();
var state = await FindAsync(filter);
var newFilter = Builders<TState>.Filter.Eq(CacheState.UniqueId, state.Id);
state.DeleteTime = TimeHelper.UnixTimeSeconds();
state.IsDeleted = true;
var result = await collection.ReplaceOneAsync(newFilter, state, ReplaceOptions);
return result.ModifiedCount;
}

/// <summary>
Expand Down

0 comments on commit 1e86355

Please sign in to comment.