@@ -18,8 +18,7 @@ class FeatureManagerSnapshot : IFeatureManagerSnapshot, IVariantFeatureManagerSn
18
18
{
19
19
private readonly IFeatureManager _featureManager ;
20
20
private readonly IVariantFeatureManager _variantFeatureManager ;
21
- private readonly ConcurrentDictionary < string , Task < bool > > _flagCache = new ConcurrentDictionary < string , Task < bool > > ( ) ;
22
- private readonly ConcurrentDictionary < string , ValueTask < bool > > _variantFlagCache = new ConcurrentDictionary < string , ValueTask < bool > > ( ) ;
21
+ private readonly ConcurrentDictionary < string , ValueTask < bool > > _flagCache = new ConcurrentDictionary < string , ValueTask < bool > > ( ) ;
23
22
private readonly ConcurrentDictionary < string , Variant > _variantCache = new ConcurrentDictionary < string , Variant > ( ) ;
24
23
private IEnumerable < string > _featureNames ;
25
24
@@ -74,26 +73,26 @@ public Task<bool> IsEnabledAsync(string feature)
74
73
{
75
74
return _flagCache . GetOrAdd (
76
75
feature ,
77
- ( key ) => _featureManager . IsEnabledAsync ( key ) ) ;
76
+ ( key ) => new ValueTask < bool > ( _featureManager . IsEnabledAsync ( key ) ) ) . AsTask ( ) ;
78
77
}
79
78
80
79
public Task < bool > IsEnabledAsync < TContext > ( string feature , TContext context )
81
80
{
82
81
return _flagCache . GetOrAdd (
83
82
feature ,
84
- ( key ) => _featureManager . IsEnabledAsync ( key , context ) ) ;
83
+ ( key ) => new ValueTask < bool > ( _featureManager . IsEnabledAsync ( key , context ) ) ) . AsTask ( ) ;
85
84
}
86
85
87
86
public ValueTask < bool > IsEnabledAsync ( string feature , CancellationToken cancellationToken )
88
87
{
89
- return _variantFlagCache . GetOrAdd (
88
+ return _flagCache . GetOrAdd (
90
89
feature ,
91
90
( key ) => _variantFeatureManager . IsEnabledAsync ( key , cancellationToken ) ) ;
92
91
}
93
92
94
93
public ValueTask < bool > IsEnabledAsync < TContext > ( string feature , TContext context , CancellationToken cancellationToken )
95
94
{
96
- return _variantFlagCache . GetOrAdd (
95
+ return _flagCache . GetOrAdd (
97
96
feature ,
98
97
( key ) => _variantFeatureManager . IsEnabledAsync ( key , context , cancellationToken ) ) ;
99
98
}
0 commit comments