1. 程式人生 > >redistemplate實現事務問題

redistemplate實現事務問題

https://www.cnblogs.com/zxf330301/p/6889202.html

 

  1. SessionCallback<Object>   sessionCallback=new SessionCallback<Object>(){  
  2.   @Override  
  3.    public Object execute(RedisOperations operations) throws DataAccessException{  
  4. operations.multi();  
  5. operations.delete("test");  
  6. operations.opsForValue.set("test","2");  
  7. Object val=operations.exec();  
  8. return val;  
  9. }  
  10. }  
  11. StringRedisTemplate.execute(sessionCallback);