Guest User

Untitled

a guest
Oct 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. import redis.clients.jedis.*;
  2. import redis.clients.jedis.exceptions.JedisException;
  3.  
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. import java.util.Set;
  7. import redis.clients.jedis.exceptions.JedisException;
  8.  
  9. public class Test {
  10.  
  11. //address of your redis server
  12. private static final String redisHost = "10.0.0.10";
  13. private static final Integer redisPort = 11211;
  14.  
  15. //remember to increase sensder queue size
  16. public void addSets() {
  17. JedisPoolConfig poolConfig = new JedisPoolConfig();
  18. poolConfig.setMaxIdle(50);
  19. poolConfig.setMaxTotal(1000);
  20. poolConfig.setTestOnBorrow(true);
  21. poolConfig.setTestOnReturn(true);
  22. JedisPool pool = new JedisPool(poolConfig,redisHost, redisPort,10000000);
  23. Jedis jedis= null;
  24. String key = "shivd";
  25. long [] bits = {1464236631,12373513,1488983657,1329373495,147236649,1623846793,1194510359,282099785,1758709929,1059647223,416962921,1893573065,924784087,551826057,2028436201};
  26.  
  27. //get a jedis connection jedis connection pool
  28. try {
  29. jedis = pool.getResource();
  30. Pipeline pipeline = jedis.pipelined();
  31.  
  32. for (long b : bits) {
  33.  
  34. pipeline.setbit(key, b, true);
  35. }
  36. pipeline.multi();
  37. pipeline.exec();
  38.  
  39. } finally {
  40. if (jedis != null) {
  41. jedis.close();
  42. }
  43. }
  44. pool.destroy();
  45.  
  46. }
  47. public static void main(String[] args){
  48. Test main = new Test();
  49. main.addSets();
  50. //main.cal();
  51. //main.addHash();
  52. }
  53. }
Add Comment
Please, Sign In to add comment