From 563b9839855cea6693f7299c24224ea620fd0c13 Mon Sep 17 00:00:00 2001 From: Haiping Chen Date: Thu, 22 Aug 2024 20:13:43 -0500 Subject: [PATCH] Add cache prefix. --- .../Infrastructures/SharpCacheAttribute.cs | 8 +++++--- src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Infrastructure/BotSharp.Abstraction/Infrastructures/SharpCacheAttribute.cs b/src/Infrastructure/BotSharp.Abstraction/Infrastructures/SharpCacheAttribute.cs index 5b7ac961..e788fc0c 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Infrastructures/SharpCacheAttribute.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Infrastructures/SharpCacheAttribute.cs @@ -10,9 +10,12 @@ public class SharpCacheAttribute : MoAttribute public static IServiceProvider Services { get; set; } = null!; private int _minutes; - public SharpCacheAttribute(int minutes) + private string _prefix; + + public SharpCacheAttribute(int minutes, string prefix = "cache") { _minutes = minutes; + _prefix = prefix; } public override void OnEntry(MethodContext context) @@ -40,8 +43,7 @@ public class SharpCacheAttribute : MoAttribute private string GetCacheKey(MethodContext context) { - // 根据用户级别生成缓存key - var key = string.Empty; + var key = _prefix; foreach (var arg in context.Arguments) { if (arg is null) diff --git a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj index 73bf035c..bf6d396a 100644 --- a/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj +++ b/src/Infrastructure/BotSharp.Core/BotSharp.Core.csproj @@ -46,10 +46,13 @@ + + +