Skip to content

Instantly share code, notes, and snippets.

@pantaluna
Forked from antirez/search.php
Created June 20, 2016 21:44
Show Gist options
  • Save pantaluna/ea05ff61069e6041b4dbf2865bc09fdb to your computer and use it in GitHub Desktop.
Save pantaluna/ea05ff61069e6041b4dbf2865bc09fdb to your computer and use it in GitHub Desktop.
<?
require("redis.php");
require("json.php");
$term = $_GET['term'];
$r = new Redis("127.0.0.1","6379");
$r->connect();
$items = $r->zrangebylex("kernel","[$term","[$term\xff",Array("LIMIT","0","10"));
$t = Array();
$id = 0;
foreach($items as $item) {
$t[] = Array("id" => $id++, "label" => $item);
}
$json = new Services_JSON();
$output = $json->encode($t);
echo($output);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment