zoukankan      html  css  js  c++  java
  • springdata中内置redis使用RedisTemplate

    RedisTemplate常用集合使用说明-boundValueOps

    boundValueOps()方法的使用:

           首先要定义一个BoundValueOperations

    BoundValueOperations boundValueOperations = redisTemplate.boundValueOps("bvo");  

     1.append(String value)

         在原来值的末尾添加值

    boundValueOperations.append("a");  
    boundValueOperations.append("b");  

    2.get(long start, long end)

        获取指定区间位置的值

    //获取所有值  
    System.out.println("获取所有值:" + boundValueOperations.get());  

     4.set(V value)

         给绑定键重新设置值

    //重新设置值  
    boundValueOperations.set("f");  
    System.out.println("重新设置值:" + boundValueOperations.get());  

    5.set(V value, long timeout, TimeUnit unit)

        在指定时间后重新设置值

    //在指定时间后重新设置  
    boundValueOperations.set("wwww",5,TimeUnit.SECONDS);  
    System.out.println("在指定时间后重新设置:" + boundValueOperations.get());  

     6.set(V value, long offset)

        截取原有值的指定长度后添加新值在后面

    //截取原有值的指定长度后添加新值在后面  
    boundValueOperations.set("nnnnnn",3);  
    System.out.println("截取原有值的指定长度后添加新值在后面:" + boundValueOperations.get());  

     7.setIfAbsent(V value)

        没有值存在则添加

     //没有值存在则添加  
    boundValueOperations.setIfAbsent("mmm");  
    System.out.println("没有值存在则添加:" + boundValueOperations.get());  

     8.getAndSet(V value)

         获取原来的值并重新赋新值

     //获取原来的值,并覆盖为新值  
    Object object = boundValueOperations.getAndSet("yyy");  
    System.out.print("获取原来的值" + object);  
    System.out.println(",覆盖为新值:" + boundValueOperations.get());  

     9.size()

        获取绑定值的长度

    System.out.println("value值的长度:" + boundValueOperations.size());  

     10.increment(double delta)和increment(long delta)

      自增长键值,前提是绑定值的类型是doule或long类型

    //自增长只能在为数字类型的时候才可以  
    boundValueOperations.increment(1);  
    System.out.println("自增长只能在为数字类型的时候才可以:" + boundValueOperations.get());
  • 相关阅读:
    shell命令--stat
    英文段子
    OCP读书笔记(16)
    shell命令--uptime
    OCP读书笔记(15)
    shell命令--dmesg
    OCP读书笔记(14)
    shell命令--hostname
    OCP读书笔记(13)
    shell命令--uname
  • 原文地址:https://www.cnblogs.com/xinghaonan/p/11900503.html
Copyright © 2011-2022 走看看