The general idea of automatic completion is described earlier, and the function of search times is now combined. I use the hash table to do, of course, can also be in the composition of the word, another ordered set to maintain the order, and then 2 ordered set of intersection can be . Here is a description of the hash method to achieve.
Generate Word dist.php
<?PHP
require'./redis.php ';//participle$words= [' Flower News ', ' NBA ', ' NBA Live ', ' NBA games ', ' NBA Playoffs ', ' NBA videos ', ' Flower News brand ', ' Flower News ', ' flower ', ' n '];//using PipelinesCache::getinstance ()pipeline ();foreach($words as $val) { $len= Mb_strlen ($val, ' Utf-8 '); for($i= 0;$i<=$len;$i++){ $key= Mb_substr ($val, 0,$i+1, ' Utf-8 '); if($i==$len) { $key. = ' * '; Cache:: getinstance ()->hset ("Search:hits",$key, 0); } Cache:: getinstance ()->zadd (' Search ', 0,$key); }}cache:: getinstance ()exec();
Auto Prompt complete.php
Complete auto-completion search function with Redis (ii)