Page 1 of 1

ajax + php auto suggest field

Posted: Tue Apr 22, 2008 4:23 am
by hame22
Hi

I have set up a auto suggest facility on a text field using php/mysql and ajax, this is working fine.

What I was wondering is whether it is possible to cache results returned. I feel that for every keystroke to connect to database each time coulkd be inefficient.

I have not worked with caching before but does anyone have any experience or suggestions?

Thanks in advance

Re: ajax + php auto suggest field

Posted: Tue Apr 22, 2008 6:49 am
by ianhull
I also have never worked with caching before but I would probably set a session with the results and store everything there, if the session isset then include the values in the list too.

If anyone else has any other suggestions I would also like to hear them :)

Re: ajax + php auto suggest field

Posted: Tue Apr 22, 2008 9:40 am
by Li0rE
yes, setting it in a session or cookie would be good (session if you have some server resources to blow or cookies if you want to screw your user :p), but if someone types in a and 1,000,000 results are going to be cached however, it would be more efficient to connect to db each time.

Re: ajax + php auto suggest field

Posted: Thu Apr 24, 2008 7:26 am
by hame22
i am limiting the results to the nearest 10.

When was talking about caching I was thinking that it would not be user dependent. ie. person a carries out a search that sql is cached person b 5 minutes later performs the same search and gets the cached results rather than resubmitting the same query. There is a pear package cache lite that may help but have no experience with it, has anyone else used alternatives?