Skip to content

Commit

Permalink
Feat/configure await (#531)
Browse files Browse the repository at this point in the history
* refactor:rename ElasticNodes -> Nodes

* feat:modify commont

* feat:update configure
  • Loading branch information
MayueCif authored Mar 30, 2023
1 parent a3fad09 commit 05c9a78
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) MASA Stack All rights reserved.
// Copyright (c) MASA Stack All rights reserved.
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

// ReSharper disable once CheckNamespace
Expand Down Expand Up @@ -71,6 +71,6 @@ public async Task TrySetValueAsync(Action existAction, Func<Task<T>>? notExistFu
{
if (IsExist) existAction.Invoke();

else if (notExistFunc != null) Value = await notExistFunc.Invoke();
else if (notExistFunc != null) Value = await notExistFunc.Invoke().ConfigureAwait(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private async Task<List<DataCacheModel<T>>> GetListAsync<T>(List<string> keys)
key = FormatCacheKey<T>(key, action);
return await GetAndRefreshAsync(key, async () =>
{
var cacheEntry = await setter();
var cacheEntry = await setter().ConfigureAwait(false);
if (cacheEntry.Value == null)
return default;
Expand Down Expand Up @@ -640,9 +640,9 @@ private RedisValue[] GetRedisValues(CacheEntryOptions? options, Func<RedisValue[
private async Task<T?> GetAndRefreshAsync<T>(string key, Func<Task<T>>? notExistFunc = null, CommandFlags flags = CommandFlags.None)
{
var redisValues = await Db.HashGetAsync(key, RedisConstant.ABSOLUTE_EXPIRATION_KEY, RedisConstant.SLIDING_EXPIRATION_KEY,
RedisConstant.DATA_KEY);
RedisConstant.DATA_KEY).ConfigureAwait(false);
var dataCacheInfo = RedisHelper.ConvertToCacheModel<T>(key, redisValues, GlobalJsonSerializerOptions);
await dataCacheInfo.TrySetValueAsync(() => Refresh(dataCacheInfo, flags), notExistFunc);
await dataCacheInfo.TrySetValueAsync(() => Refresh(dataCacheInfo, flags), notExistFunc).ConfigureAwait(false);
return dataCacheInfo.Value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public Dictionary<string, string> GetValues()
ConfigMap[MasaStackConfigConstant.CLUSTER],
DEFAULT_PUBLIC_ID,
DEFAULT_CONFIG_NAME).ConfigureAwait(false).GetAwaiter().GetResult();

return remoteConfigs;
}
catch (ArgumentException)
Expand Down

0 comments on commit 05c9a78

Please sign in to comment.