Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions BotSharp.Core/AgentStorage/AgentStorageInMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
using BotSharp.Platform.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq;
using System.Threading.Tasks;

namespace BotSharp.Core.AgentStorage
Expand Down
14 changes: 6 additions & 8 deletions BotSharp.Core/AgentStorage/AgentStorageInRedis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public AgentStorageInRedis()
public async Task<TAgent> FetchById(string agentId)
{
var key = agentId;
if (csredis.Exists(key))
if (await csredis.ExistsAsync(key))
{
return JsonConvert.DeserializeObject<TAgent>(csredis.Get(key));
return JsonConvert.DeserializeObject<TAgent>(await csredis.GetAsync(key));
}
else
{
Expand All @@ -46,12 +46,10 @@ public async Task<TAgent> FetchById(string agentId)

public async Task<TAgent> FetchByName(string agentName)
{
var agents = new List<TAgent>();

var keys = csredis.Keys($"{prefix}*");
foreach (string key in keys)
{
var data = csredis.Get(key.Substring(prefix.Length));
var data = await csredis.GetAsync(key.Substring(prefix.Length));
var agent = JsonConvert.DeserializeObject<TAgent>(data);

if(agent.Name == agentName)
Expand All @@ -76,7 +74,7 @@ public async Task<bool> Persist(TAgent agent)
Formatting = Formatting.Indented,
});

csredis.Set(agent.Id, json);
await csredis.SetAsync(agent.Id, json);

return true;
}
Expand All @@ -85,7 +83,7 @@ public async Task<int> PurgeAllAgents()
{
var keys = csredis.Keys($"{prefix}*");

csredis.Del(keys.Select(x => x.Substring(prefix.Length)).ToArray());
await csredis.DelAsync(keys.Select(x => x.Substring(prefix.Length)).ToArray());

return keys.Count();
}
Expand All @@ -97,7 +95,7 @@ public async Task<List<TAgent>> Query()
var keys = csredis.Keys($"{prefix}*");
foreach (string key in keys)
{
var data = csredis.Get(key.Substring(prefix.Length));
var data = await csredis.GetAsync(key.Substring(prefix.Length));
var agent = JsonConvert.DeserializeObject<TAgent>(data);
agents.Add(agent);
}
Expand Down