当前位置:网站首页>Difference between boundvalueops and opsforvalue

Difference between boundvalueops and opsforvalue

2022-06-27 07:16:00 Exquisite·

    /** obtain a, And get b, Then delete c, To the same key There are multiple operations , according to opsForHash() Writing  *  Every time redisTemplate.opsForHash().xxx("key","value") The writing is very wordy  */
    int result = (Integer) redisTemplate.opsForHash().get("hash-key","a");
    result = (Integer)redisTemplate.opsForHash().get("hash-key","b");
    redisTemplate.opsForHash().delete("hash-key","c");
 
    /** * boundHashOps() It's going directly to key and boundHashOperations Object is bound , *  Go straight through boundHashOperations Object to perform relevant operations , The writing is concise , Unwanted  *  Each time, it will explicitly key Write out  */
    BoundHashOperations<String, String, Object> boundHashOperations = redisTemplate.boundHashOps("hash-key");
    result = (Integer) boundHashOperations.get("a");
    result = (Integer) boundHashOperations.get("b");
    boundHashOperations.delete("c");
    
    // The above is my humble opinion , If there is any wrong , Welcome to correct 
原网站

版权声明
本文为[Exquisite·]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206270650101550.html