Guest User

Jason Young

a guest
Sep 1st, 2009
298
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $MC = new Memcached;
  3. $MC->setOption(Memcached::OPT_BINARY_PROTOCOL, true); // Removing this causes the code to work, but at the 'expense' of reverting to the ASCII protocol
  4. $MC->addServer('10.10.10.5', 64261);
  5.  
  6. $KeyList = Array (
  7.     'GTID:%09%5d%3bhe)j3sq',
  8.     'GTID:%09%5d%3bhe)j2q%03',
  9.     'GTID:%09%5d%3bhe)j3%03%07',
  10.     'GTID:%09%5d%3bhe)j2s%05',
  11.     'GTID:%09%5d%3bhe)j2%7c%09',
  12.     'GTID:%09%5d%3bhe)j2%7d%7b',
  13.     'GTID:%09%5d%3bhe)j3rx',
  14.     'GTID:%09%5d%3a%15%18*iAr%07',
  15.     'GTID:%09%5d%3a%13%1f%5c%1eGtw',
  16.     'GTID:%09%5d%3abn%2bi6%04%01',
  17.     'GTID:%09%5d%3bhe)j%3c%0ft',
  18.     'GTID:%09%5d%3abn%5c%1e9%7e%0a',
  19.     'GTID:%09%5d%3bhe)j3p%01',
  20.     'GTID:%09%5d%3a%15%18*iN%0er',
  21.     'GTID:%09%5d%3a%15%18*iAss',
  22.     'GTID:%09%5d%3a%15%18*iNe4X6z-17t'
  23. );
  24.  
  25. $Test = Array();
  26. foreach ($KeyList as $k) {
  27.     $Test[$k] = "My Key is $k!";
  28. }
  29.  
  30. // This block uses the *Multi() functions
  31. $MC->setMulti($Test, 3600);
  32.  
  33. sleep(1);
  34.  
  35. $theList = $MC->getMulti($KeyList);
  36. print_r($theList); // Verify that all keys are intact
  37.  
  38. foreach ($theList as $K => $V) {
  39.     echo isset($theList[$K]) ? str_pad($K, 40)." Found: \"{$theList[$K]}\"\n" : str_pad($K, 40)." NOT Found\n";
  40. }
  41.  
  42. /* ===== */
  43.  
  44. /*
  45. // This block uses single get/set operations, which do not exhibit the same issues
  46.  
  47. foreach ($Test as $K => $V) {
  48.     $MC->set($K, $V, 3600);
  49. }
  50.  
  51. sleep(1);
  52.  
  53. foreach ($Test as $K => $V) {
  54.     echo ($Res = $MC->get($K)) ? str_pad($K, 40)." Found:" : str_pad($K, 40)." NOT Found:";
  55.     echo "\t\"$Res\"\n";
  56. }
  57. */
  58. ?>
RAW Paste Data