Created
April 20, 2012 10:59
-
-
Save wdalmut/2427774 to your computer and use it in GitHub Desktop.
Example for upcloo-autocomplete test run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have to remove Memcached compression option!