Skip to content

Commit

Permalink
- add Notice event "ClientSideCaching:InValidate";#168
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Dec 14, 2023
1 parent acac1d1 commit ce14d3b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions examples/console_net8_client_side_caching/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ static void Main(string[] args)
Thread.CurrentThread.CurrentCulture = new CultureInfo("nb");
var test = long.Parse("-1");

cli.Notice += (s, e) =>
{
if (e.NoticeType == NoticeType.Event && e.Log == "ClientSideCaching:InValidate")
{
var keys = e.Tag as string[];
}
};
cli.UseClientSideCaching(new ClientSideCachingOptions
{
//本地缓存的容量
Expand Down
3 changes: 2 additions & 1 deletion src/FreeRedis/ClientSideCaching.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ void InValidate(string chan, object msg)
{
foreach (var key in keys)
RemoveCache(string.Concat(key));
}
_cli.OnNotice(_cli, new NoticeEventArgs(NoticeType.Event, null, "ClientSideCaching:InValidate", keys));
}
}

static readonly DateTime _dt2020 = new DateTime(2020, 1, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/FreeRedis/RedisClientEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace FreeRedis
{
public enum NoticeType
{
Call, Info
Call, Info, Event
}
public class NoticeEventArgs : EventArgs
{
Expand Down

0 comments on commit ce14d3b

Please sign in to comment.