2881099 / FreeRedis

🦄 FreeRedis is .NET40+ redis client. supports cluster, sentinel, master-slave, pub-sub, lua, pipeline, transaction, streams, client-side-caching, and pooling.
MIT License
920 stars 164 forks source link

期望client-side-caching可以暴露出一个handle来处理过期的缓存 #168

Open wosledon opened 10 months ago

wosledon commented 10 months ago

默认是直接删除本地缓存,但是缓存有时不一定是静态数据,而是动态数据,需要做一些更新处理。例如采用动态编译技术实现的动态接口,需要更新后编译到当前环境。

2881099 commented 10 months ago
cli.Notice += (s, e) =>
{
    if (e.NoticeType == NoticeType.Event && e.Log == "ClientSideCaching:InValidate")
    {
        var keys = e.Tag as string[];
    }
};
cli.UseClientSideCaching(new ClientSideCachingOptions
{
    //本地缓存的容量
    Capacity = 3,
    //过滤哪些键能被本地缓存
    //KeyFilter = key => key.StartsWith("Interceptor"),
    //检查长期未使用的缓存
    CheckExpired = (key, dt) => DateTime.Now.Subtract(dt) > TimeSpan.FromSeconds(600)
});