Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. // variables
  2. private static Object staticLock = new Object();
  3. private static JedisPool pool;
  4. private JedisPoolConfig jpc;
  5.  
  6. // methods
  7. private void setupRedis() {
  8. JedisPoolConfig jd = new JedisPoolConfig();
  9. jd.setMaxWaitMillis(1000L);
  10. jd.setMinIdle(5);
  11. jd.setTestOnBorrow(true);
  12. jd.setMaxTotal(20);
  13. jd.setBlockWhenExhausted(true);
  14. this.jpc = jd;
  15. }
  16. public JedisPool getPool() {
  17. if (pool == null) {
  18. synchronized(staticLock) {
  19. if (pool == null) {
  20. pool = new JedisPool(this.jpc,this.address,this.port);
  21. }
  22. }
  23. }
  24. return pool;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement