Skip to content

Commit fb0a3ac

Browse files
Switch PreferMultipleGet to virtual, and false by default
1 parent 4061f46 commit fb0a3ac

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/NHibernate/Async/Cache/CacheBase.cs

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ public abstract partial class CacheBase :
3333
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
3434
/// <returns>The cached items, matching each key of <paramref name="keys"/> respectively. For each missed key,
3535
/// it will contain a <see langword="null" />.</returns>
36+
/// <remarks>
37+
/// <para>As all other <c>Many</c> method, its default implementation just falls back on calling
38+
/// the single operation method in a loop. Cache providers should override it with an actual multiple
39+
/// implementation if they can support it.</para>
40+
/// <para>Additionally, if overriding <c>GetMany</c>, consider overriding also
41+
/// <see cref="PreferMultipleGet"/>.</para>
42+
/// </remarks>
3643
public virtual Task<object[]> GetManyAsync(object[] keys, CancellationToken cancellationToken)
3744
{
3845
if (keys == null)

src/NHibernate/Cache/CacheBase.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public abstract partial class CacheBase :
6161
/// </summary>
6262
/// <remarks>
6363
/// <para>
64+
/// <see cref="CacheBase"/> implementation always yield <c>false</c>, override it if required.
65+
/// </para>
66+
/// <para>
6467
/// This property should yield <see langword="false" /> if <see cref="GetMany" /> delegates
6568
/// its implementation to <see cref="Get"/>.
6669
/// </para>
@@ -75,7 +78,7 @@ public abstract partial class CacheBase :
7578
/// gets to perform. Its <see cref="CacheBase" /> default implementation is adequate for this case.
7679
/// </para>
7780
/// </remarks>
78-
public abstract bool PreferMultipleGet { get; }
81+
public virtual bool PreferMultipleGet => false;
7982

8083
#region Basic abstract operations
8184

@@ -141,6 +144,13 @@ public abstract partial class CacheBase :
141144
/// <param name="keys">The keys to be retrieved from the cache.</param>
142145
/// <returns>The cached items, matching each key of <paramref name="keys"/> respectively. For each missed key,
143146
/// it will contain a <see langword="null" />.</returns>
147+
/// <remarks>
148+
/// <para>As all other <c>Many</c> method, its default implementation just falls back on calling
149+
/// the single operation method in a loop. Cache providers should override it with an actual multiple
150+
/// implementation if they can support it.</para>
151+
/// <para>Additionally, if overriding <c>GetMany</c>, consider overriding also
152+
/// <see cref="PreferMultipleGet"/>.</para>
153+
/// </remarks>
144154
public virtual object[] GetMany(object[] keys)
145155
{
146156
if (keys == null)

0 commit comments

Comments
 (0)