Example:
@Autowired stringredistemplate redistemplate; @Override Public voidDealredis (Dealer Dealer) {Dealer=Dao.findbyuid (Dealer.getuid ()); String Tid=Dealer.gettenementid (); Hashoperations<string, Object, object> ofh =Redistemplate.opsforhash (); Field[] Declaredfields=Dealer.getclass (). Getdeclaredfields (); for(Field declaredfield:declaredfields) {String name=Declaredfield.getname (); if(Name.equals ("id") | | name.equals ("TID")){ Continue; }Else{ofh.increment (tid,name,111); }} Map<object, object> entries =ofh.entries (TID); System.out.println (The Get map>>>>>>>>>>>>>>>>>>>>>>>>>> "+entries.tostring ()); Set<Object> keys =Ofh.keys (TID); System.out.println ("Get set>>>>>>>>>>>>>>>>>>>>> of key" +keys.tostring ()); List<Object> values =ofh.values (TID); System.out.println ("Get list>>>>>>>>>>>>>>>>>>>>> of values" +values.tostring ()); Ofh.delete (Tid,keys.toarray ()); System.out.println ("Delete Success >>>>>>>>>>>>>>>>>>>>>>>>>>"); Map<object, object> entries2 =ofh.entries (TID); System.out.println (">>>>>>>>>>>>>>>>>>>>>>>>>>" +entries2.tostring ()); for(Object key:keys) {ofh.increment (Tid,key,111); } Map<object, object> entries3 =ofh.entries (TID); System.out.println (">>>>>>>>>>>>>>>>>>>>>>>>>>" +entries3.tostring ()); for(Object key:keys) {ofh.increment (Tid,key,-11); } Map<object, object> entries4 =ofh.entries (TID); System.out.println (">>>>>>>>>>>>>>>>>>>>>>>>>>" +entries4.tostring ()); Ofh.delete (Tid,keys.toarray ()); System.out.println ("Delete Success >>>>>>>>>>>>>>>>>>>>>>>>>>"); for(Object key:keys) {ofh.increment (Tid,key,-11); } Map<object, object> entries5 =ofh.entries (TID); System.out.println (">>>>>>>>>>>>>>>>>>>>>>>>>>" +entries5.tostring ()); }
Results:
Redis hash operation in "Redis" Spring boot