fix: added temporary method to clear collections cache
This commit is contained in:
parent
9db458d720
commit
37e56206d4
@ -29,6 +29,8 @@ namespace Core.Blueprint.DAL.Mongo.Service
|
|||||||
|
|
||||||
await this.repository.InsertOneAsync(sampleCollection);
|
await this.repository.InsertOneAsync(sampleCollection);
|
||||||
|
|
||||||
|
await ResetCollectionCache();
|
||||||
|
|
||||||
return sampleCollection;
|
return sampleCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,14 +68,32 @@ namespace Core.Blueprint.DAL.Mongo.Service
|
|||||||
{
|
{
|
||||||
await this.repository.ReplaceOneAsync(entity);
|
await this.repository.ReplaceOneAsync(entity);
|
||||||
|
|
||||||
|
await ResetCollectionCache();
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async ValueTask<SampleCollection> DeleteSample(string _id, CancellationToken cancellationToken)
|
public async ValueTask<SampleCollection> DeleteSample(string _id, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var entity = await this.repository.DeleteOneAsync(doc => doc._Id == _id);
|
var entity = await this.repository.DeleteOneAsync(doc => doc._Id == _id);
|
||||||
|
|
||||||
|
await ResetCollectionCache();
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Temporary method to "reset" collections cache
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task ResetCollectionCache()
|
||||||
|
{
|
||||||
|
//TODO: remoge this mehtod when necessary.
|
||||||
|
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllSamples");
|
||||||
|
|
||||||
|
await cacheProvider.SetAsync(cacheKey, Enumerable.Empty<SampleCollection>(), null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user