Skip to content

Instantly share code, notes, and snippets.

@wdalmut
Created April 20, 2012 10:59
Show Gist options
  • Save wdalmut/2427774 to your computer and use it in GitHub Desktop.
Save wdalmut/2427774 to your computer and use it in GitHub Desktop.
Example for upcloo-autocomplete test run
<?php
$jsonp = false;
if ($_GET["callback"]) {
$jsonp = $_GET["callback"];
}
$memcached = new Memcached();
$memcached->addServer("127.0.0.1", 11211);
$memcached->setOption(Memcached::OPT_COMPRESSION, false);
$sitekey = $_GET["sitekey"];
$word = $_GET["word"];
$key = "{$sitekey}_{$word}";
$list = array();
for ($i=0; $i<10; $i++) {
$rand = sha1(rand(0,100000));
$list[] = $word."-".$rand;
}
$list = json_encode($list);
$memcached->add($key, $list, 300);
if ($jsonp) {
echo $jsonp."({$list})";
} else {
echo $list;
}
@wdalmut
Copy link
Author

wdalmut commented Apr 20, 2012

You have to remove Memcached compression option!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment