Skip to content

Instantly share code, notes, and snippets.

@kornelski
Forked from antirez/search.php
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kornelski/11177056 to your computer and use it in GitHub Desktop.
Save kornelski/11177056 to your computer and use it in GitHub Desktop.
Codegolfed
<?
require("redis.php");
$term = $_GET['term'];
$r = new Redis("127.0.0.1","6379");
$r->connect();
$items = $r->zrangebylex("kernel", "[$term", "[$term\xff", ["LIMIT","0","10"]);
$t = [];
foreach($items as $id => $item) {
$t[] = ["id" => $id, "label" => $item];
}
echo json_encode($t);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment