Advertisement
Guest User

Untitled

a guest
Jul 29th, 2010
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. brianm (dev) ~ # cat memcached2.php
  2. <?php
  3.  
  4. $pid = getmypid();
  5.  
  6. for($x=0;$x<20;$x++) {
  7.  
  8. $mc = new Memcached("test");
  9. if ( count( $mc->getServerList() ) < 1 )
  10. $mc->addServer("localhost", 11211);
  11. $mc->get("foo");
  12. unset($mc);
  13.  
  14. $connections = `lsof -n -p $pid | fgrep -c "11211"`;
  15.  
  16. echo "$x: $connections";
  17. }
  18.  
  19. ?>
  20. brianm (dev) ~ # php memcached2.php
  21. 0: 1
  22. 1: 1
  23. 2: 1
  24. 3: 1
  25. 4: 1
  26. 5: 1
  27. 6: 1
  28. 7: 1
  29. 8: 1
  30. 9: 1
  31. 10: 1
  32. 11: 1
  33. 12: 1
  34. 13: 1
  35. 14: 1
  36. 15: 1
  37. 16: 1
  38. 17: 1
  39. 18: 1
  40. 19: 1
  41. brianm (dev) ~ # cat memcache.php
  42. <?php
  43.  
  44. $pid = getmypid();
  45.  
  46. for($x=0;$x<20;$x++) {
  47.  
  48. $mc = new Memcache();
  49. $mc->addServer("localhost", 11211, true);
  50. $mc->get("foo");
  51. unset($mc);
  52.  
  53. $connections = `lsof -n -p $pid | fgrep -c "11211"`;
  54.  
  55. echo "$x: $connections";
  56. }
  57.  
  58. ?>
  59. brianm (dev) ~ # php memcache.php
  60. 0: 1
  61. 1: 1
  62. 2: 1
  63. 3: 1
  64. 4: 1
  65. 5: 1
  66. 6: 1
  67. 7: 1
  68. 8: 1
  69. 9: 1
  70. 10: 1
  71. 11: 1
  72. 12: 1
  73. 13: 1
  74. 14: 1
  75. 15: 1
  76. 16: 1
  77. 17: 1
  78. 18: 1
  79. 19: 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement