forked from ravendb/ravendb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RavenDB-23183 - ensure the cached items are cleared before returning …
…the array to the ArrayPool
- Loading branch information
1 parent
13b7a21
commit f1b08f7
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using FastTests; | ||
using Raven.Tests.Core.Utils.Entities; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace StressTests.Client | ||
{ | ||
public class MultiGet : RavenTestBase | ||
{ | ||
public MultiGet(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task MultiGetCanGetFromCache() | ||
{ | ||
var store = GetDocumentStore(); | ||
|
||
using (var bulk = store.BulkInsert()) | ||
{ | ||
for (var i = 0; i < 10_000; i++) | ||
{ | ||
await bulk.StoreAsync(new User { Id = $"Users/{i}", Count = i }); | ||
} | ||
} | ||
|
||
async Task Fetch() | ||
{ | ||
for (var i = 0; i < 64; i++) | ||
{ | ||
using (var session = store.OpenAsyncSession()) | ||
{ | ||
var n1 = Random.Shared.Next(0, 10_000); | ||
var n2 = Random.Shared.Next(0, 10_000); | ||
session.Advanced.Lazily.LoadAsync<User>($"Users/{n1}"); | ||
session.Advanced.Lazily.LoadAsync<User>($"Users/{n2}"); | ||
await session.Advanced.Eagerly.ExecuteAllPendingLazyOperationsAsync(); | ||
|
||
var loaded1 = await session.LoadAsync<User>($"Users/{n1}"); | ||
Assert.Equal(n1, loaded1.Count); | ||
|
||
var loaded2 = await session.LoadAsync<User>($"Users/{n2}"); | ||
Assert.Equal(n2, loaded2.Count); | ||
} | ||
} | ||
} | ||
|
||
var tasks = new List<Task>(); | ||
for (var i = 0; i < 100; i++) | ||
{ | ||
tasks.Add(Task.Run(Fetch)); | ||
} | ||
|
||
await Task.WhenAll(tasks); | ||
} | ||
} | ||
} |