zoukankan      html  css  js  c++  java
  • Spring RedisTemplate操作-哈希操作(3)

    @Autowired
    @Resource(name="redisTemplate")
    private RedisTemplate<String, String> rt;

    public void flushdb(){
    rt.execute(new RedisCallback<Object>() {
    public String doInRedis(RedisConnection connection) throws DataAccessException {
    connection.flushDb();
    return "ok";
    }
    });
    }

    public void set(){
    flushdb();
    HashOperations<String, String, String> vo = rt.opsForHash();
    vo.put("book", "wzg", "dsg");
    Map<String, String> map = new HashMap<String, String>();
    map.put("cff", "xsg");
    map.put("cl", "xxsg");
    vo.putAll("book", map);
    vo.putIfAbsent("book", "mc", "www");
    vo.increment("book", "yw", 1l);

    vo.delete("book", "cl","yw");
    }

    public void get(){
    HashOperations<String, String, String> vo = rt.opsForHash();
    out(vo.get("book", "wzg"));
    out(String.valueOf(vo.get("book", "yw")));
    out(vo.multiGet("book", Arrays.asList("wzg","cff","cl","mc")));
    out(vo.hasKey("book", "wzg"));
    out(vo.entries("book"));
    out(vo.keys("book"));
    out(vo.values("book"));
    out(vo.size("book"));

    }

    public void out(String str){
    System.out.println(str);
    }
    public void out(Collection list){
    System.out.println(list);
    }
    public void out(long num){
    System.out.println(num);
    }
    public void out(Integer num){
    System.out.println(num);
    }
    public void out(boolean num){
    System.out.println(num);
    }
    public void out(Map num){
    System.out.println(num);
    }

  • 相关阅读:
    ACM-超级楼梯
    clientt.c
    call.c
    answer.c
    aa.c
    client.c
    service.c
    自己动手开发jQuery插件
    apache-commons-net Ftp 进行文件、文件夹的上传下载及日志的输出
    在Eclipse中制作SSH配置文件提示插件
  • 原文地址:https://www.cnblogs.com/aoeiuv/p/6760732.html
Copyright © 2011-2022 走看看