Last active
December 16, 2023 19:56
-
-
Save antirez/11126283 to your computer and use it in GitHub Desktop.
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
<? | |
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); | |
?> |
Warning: fsockopen() [For instance many configuration options can be modified without any kind of restart using the function.fsockopen]: unable to connect to 127.0.0.1:10001 (Connection refused) in /var/virtual/autocomplete.redis.io/httpdocs/redis.php on line 29
Fatal error: Cannot open socket to 127.0.0.1:10001, error 111. in /var/virtual/autocomplete.redis.io/httpdocs/redis.php on line 37
I am unsure how this works as I cannot find support for zrangebylex with PHP anywhere.
Seems like demo script doesn't work for several years :-(
You can use predis library and call ZSetRangeByLex
By any chance has anyone an example project on how to store the data, index it and the UI for autocomplete?
Thank you in advance.
Michal
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
could you share the source of redis.php?
every redis-php library i find, dont support "zrangebylex"