More autocompletion with Redis and Drupal

Last week I began working on an auto-complete function using Redis behind Drupal 7 to do some auto-completing functions.

I needed to get some county data, and possibly other sorts, put into some forms so that it can be standardised. One of the issues that I’ve been trying to do is to make sure that data is clean across various systems.

One of the issues that has come up is the connection library to the Redis server. I’ve used Nicholas FF’s phpredis library and the Rediska library. The matters that I’ve been considering are the size and complexity of each library.

I do like phpredis but as it is a C library needs compiling so that puts a potential barrier to its use in Drupal. Also the user may not have root access to compile it. As earlier posts might show, I loved Rediska but it seems overly large and complex for such a slight task. I was running some tests today on another project and it did not appear to be closing its connections properly (an issue which might be ‘QDH’able in the short term). Both libraries are complete and large which is what makes them great Swiss Army knives for Redis and PHP.

But I would like something small and light that has access to a subset of commands and is pure PHP. I suppose a long term desire might be to implement some of the pub/sub commands but I cannot think of a use at the moment.

I’ve taken ideas from Salvatore Sanfillipo’s post which uses Ruby and ported these into PHP so the code uses Redis’s sorted sets to get the relevant items. I need to complete the code to see how it fairs under AJAX in Drupal. It would be a great sidetrack to follow some of the other possibilities such as search prediction, or perhaps this might go sideways into using that to pull up homonyms or synonyms where these are stored.

But that is definitely another day and another project.