jquery-tokeninput
jquery-tokeninput copied to clipboard
Updated caching performance
Designed to reuse the cached results of a previous search where that search had a broader query than the current query. When reuseLargerResult is set to "true" and the current query is not in the cache, we loop through the query string removing the last character each time and check to see if the shorter version is in the cache. If it is, then we filter those cached results to just be the ones that match the current query, then add those to the cache for the current query.
For example, a user has finished typing the "t" in "cat", which is not in the cache. We check to see if the results for the search that was done after they typed the "a" previously is cached, because any results that would come back for "cat" would already be in the results for "ca". This works best for server-data sources, and is intended to be used when "resultsLimit" is left as null (unless you want your subset to be based on the restricted number of previous results).
I haven't decided if it's more beneficial to cache the smaller subset, or to limit the number of caches and just filter the larger subset each time. I'm sure there's a bell-shaped graph that can show this kind of thing.