• SpringDataRedis持续更新部分值使用方式


    官方文档:https://docs.spring.io/spring-data/redis/docs/2.3.4.RELEASE/reference/html/#redis.repositories.partial-updates

    SpringDataRedis文档13.9部分介绍了使用持续部分更新值的方式,但是文中的template对象并没有说明是Repository对象还是RedisKeyValueTemplate对象,所以,下面分析以下代码:

    Redis提供了org.springframework.data.keyvalue.repository.KeyValueRepository仓库接口,对应的实现类:org.springframework.data.keyvalue.repository.support.SimpleKeyValueRepository

    分析 SimpleKeyValueRepository 类:

     方法签名:org.springframework.data.keyvalue.core.KeyValueTemplate#insert(T objectToInsert) 

     

     

     先看以下execute的方法主体

     1:意思就是说函数接口Lambda表达式最终通过调用org.springframework.data.redis.core.RedisKeyValueAdapter#put方法

    目前分析到这里

    接下来分析RedisKeyValueTemplate实现类

     第一个update方法的super.update语句就是调用KeyValueTemplate实现类中转了一下

     上图是第一个update方法调用的中转的语句主题,最终调用的位置都是一样的

    我们想使用Redis的持续更新部分值,那么就需要使用

    PartialUpdate类

     

     上图是官方文档的使用说明。

    所以操作Repository和操作RedisKeyValueTemplate类的功能不会少,就是 通知事件,更新生存时间都会进而更新的,,,

    以上内容都是通过代码排查,并未进行过精确的Debug分析,如有错误,请提醒

    复制请注明出处,在世界中挣扎的灰太狼
  • 相关阅读:
    ios属性或者变量的前缀-杂记
    xcode注释方法
    ios 不同的数据类型转化为json类型
    第一部分----HTML的基本结构与基本标签
    Git使用总结
    c#后台弹出框
    svn下载安装
    svn配置
    access 日期转换
    C# 中关于汉字与16进制转换的代码
  • 原文地址:https://www.cnblogs.com/XingXiaoMeng/p/13832436.html
Copyright © 2020-2023  润新知