Advertisement
Guest User

Huy Phan

a guest
Apr 26th, 2009
1,013
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. <?php
  2.  
  3. $memcached_obj = memcache_connect('localhost',11211);
  4.  
  5. $keysize = 300;
  6. $total = 100000;
  7.  
  8. // Initialize values
  9. $s = array();
  10. for ($k=0;$k<10;$k++)
  11. {
  12.     $s[$k] = "";
  13.     for ($i=0;$i<$keysize;$i++) $s[$k].=$k;
  14. }
  15.  
  16. // Setting values
  17. for ($i=0;$i<$total;$i++)
  18. {    
  19.     memcache_set($memcached_obj,'huy'.$i,$s[$i%10]);
  20. }
  21.  
  22. $count = 0;
  23. // Get them back and count
  24. for ($i=0;$i<$total;$i++)
  25. {
  26.     $v = memcache_get($memcached_obj,'huy'.$i);
  27.     if (!$v) $count++;
  28.     elseif ($v != $s[$i%10]) $count++;
  29. }
  30.  
  31. echo "Missed ".$count."/".$total."\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement