マルチExecの時計を使用してRedisTemplateトランザクション処理方法

    @Autowired 
    RedisTemplate <文字列、文字列> redisTemplate。


        redisTemplate.execute(新しい SessionCallback <OBJECT> (){ 

            @Override 
            公共 <K、V>オブジェクトの実行(RedisOperations <K、V>操作)がスローDataAccessException {
                 // 开启事务
                ; operations.multiを()
                 のためのint型 I = 1 ; iが5 = <; iは++ ){ 
                    redisTemplate.convertAndSend( "号我是消息{%のD}:%TT" "チャネル試験"、String.Formatの(I、新しい日付())); 
                    redisTemplate.opsForValueを( )。セット("キー" + I、 "キー" + Iを); 
                } 
                // トランザクションを実行
                operations.execを();
                 戻り値 はnull ; 
            } 
        });

 

おすすめ

転載: www.cnblogs.com/powerwu/p/11505716.html