Created
March 14, 2014 02:14
-
-
Save yakolla/9540996 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Handles requests for the application home page. | |
*/ | |
@Controller | |
@RequestMapping(value="/home") | |
public class HomeController { | |
private static final Logger logger = LoggerFactory.getLogger(HomeController.class); | |
@Autowired | |
RedisTemplate<String, Object> redisTemplate; | |
@RequestMapping(value="/jedis6/{count}") | |
public String jedis6(@PathVariable final int count){ | |
redisTemplate.setKeySerializer(new StringRedisSerializer()); | |
redisTemplate.execute(new SessionCallback<Object>() { | |
@Override | |
public Object execute(RedisOperations operations) | |
throws DataAccessException { | |
operations.multi(); | |
String key; | |
for (int i = 0; i < count; ++i) | |
{ | |
User user = new User(); | |
user.setId(i); | |
user.setName("warwick" + i); | |
user.setLevel(Level.SILVER); | |
key = "foo:" + i; | |
operations.opsForValue().set(key, user); | |
} | |
operations.exec(); | |
return null; | |
} | |
}); | |
return "home"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment