Utilities.ClearCache
This commit is contained in:
parent
4c6c035b07
commit
b3311a1917
|
|
@ -60,6 +60,8 @@ public partial class AgentService
|
|||
_db.Add<IBotSharpTable>(userAgentRecord);
|
||||
});
|
||||
|
||||
Utilities.ClearCache();
|
||||
|
||||
return agentRecord;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using BotSharp.Abstraction.Agents.Models;
|
||||
using BotSharp.Abstraction.Conversations.Models;
|
||||
using BotSharp.Abstraction.Repositories;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using System.IO;
|
||||
|
||||
namespace BotSharp.Core.Agents.Services;
|
||||
|
|
@ -51,5 +51,7 @@ public partial class AgentService
|
|||
|
||||
_db.BulkInsertAgents(agents);
|
||||
_db.BulkInsertUserAgents(userAgents);
|
||||
|
||||
Utilities.ClearCache();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ public partial class AgentService
|
|||
}
|
||||
|
||||
_db.UpdateAgent(record, updateField);
|
||||
|
||||
Utilities.ClearCache();
|
||||
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
|
@ -66,6 +69,8 @@ public partial class AgentService
|
|||
.SetLlmConfig(foundAgent.LlmConfig);
|
||||
|
||||
_db.UpdateAgent(clonedAgent, AgentField.All);
|
||||
|
||||
Utilities.ClearCache();
|
||||
}
|
||||
|
||||
await Task.CompletedTask;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace BotSharp.Core.Infrastructures;
|
||||
|
||||
public static class Utilities
|
||||
|
|
@ -20,4 +22,13 @@ public static class Utilities
|
|||
var splits = str.Split(sep);
|
||||
return (splits[0], splits[1]);
|
||||
}
|
||||
|
||||
public static void ClearCache()
|
||||
{
|
||||
// Clear whole cache.
|
||||
if (new MemoryCacheAttribute(0).Cache is MemoryCache memcache)
|
||||
{
|
||||
memcache.Compact(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
using BotSharp.Abstraction.Agents.Models;
|
||||
using BotSharp.Abstraction.Functions.Models;
|
||||
|
||||
namespace BotSharp.OpenAPI.Controllers;
|
||||
|
||||
[Authorize]
|
||||
|
|
|
|||
Loading…
Reference in a new issue