-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method to clear dataset cache or make it context configurable (page or DOM element) #221
Comments
Incidentally, a pull like the one proposed for #95 (pull #220) would permit circumventing the Typeahead.js cache; you could manage your own cache, e.g. with a request management library like amplify.js or model/collection/view manager like Backbone.js. |
I am using mixed sources for my single page app, some backbone collections and some raw prefetch urls. So would still be helpful to notify typehead to clear the cache somehow. |
Please consider this :) Thanks! |
+1 on cache flush. In a feature I am working on we add resources from the backend, and once resource is added, you can't added again. the way typeahead caches it is impossible to exclude it from the result set. I ended up cheating and setting a random name + a random string in the URI to work around it, but ideally clearing the cache would be cleaner. |
+1 |
+1 |
2 similar comments
+1 |
+1 |
This should probably be done by default in the destroy method, since if we destroy a typeahead, we generally don't care about the backing store any longer so it shouldn't be kept in memory. |
+1 |
6 similar comments
👍 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 Unpleasantly surprised when I figured out that typeahead( 'destroy'), doesn't do this, "destroy" to me implies razed to the ground, plant salt, etc. |
+1 |
1 similar comment
+1 |
I have the same problem with destroy... to quick fix simple add line cache = new Array(); to the destroy function .... |
https://github.com/tellex/typeahead.js/commit/7a10abf0fd958883b2b009622caa977b15d26994 Added refreshCache method. So if you have multiple datasets binded to a typehead and u need to change a particular dataset value simple call $(".input-box").typeahead("refreshCache",[{name:Dataset1, url: "New URL"}]); -> Is important to always add "[]" because refreshCache expects an array of objects. This function will find all dataset cached to the typeahead and walk trought the array to find the matching dataset.name then it will check which attributes values changed and replace the new ones , refresh the associated cache object, and reinitialize the typeahead. I added an new event called typeahead:dropdownOpened the reason behind this is that if add a new refreshCache dataset i will reinitialize the typeahead and destroy previously DOM created object ... so if u have binded an event to a element in the displayed suggestions Box it will be lost.... the solution to this: Hope you enjoy the new function , sorry for my bad grammar my native languaje is spanish.... Greetings from argentina!!! |
I'm sorry, but how can I destroy all the caches? I tried but it throws an error: one of local, prefetch, or remote is required. isn't there an easier way to just refresh all the caches? what is the default expiration of the cache? |
FYI in v0.10 there won't be a dataset cache so this should no longer be an issue. |
I'm a little confused by the versioning here. I am using 0.9.3 which in my understanding is far greater than 0.10 ? or by 0.10 you mean 0.10.1? |
I mean v0.10.0 which is greater than v0.9.3. |
I found that the following line clears the cache: This of course clears everything out of the localstorage. But since I didn't have anything interesting in there, this was enough for me. |
v0.10.0 has been released so this should no longer be an issue. |
I'm still having an issue with this and I've got v0.10.1, but I suspect the issue is in the bloodhound repo. Edit: To clarify, the issue that is no longer an issue, is no longer an issue. (I think that issue is the one where a dataset was page level, there are now options to have different datasets, sweet.) The issue I was having was the difficulty of clearing the cache, which this issue also touches on. My solution was to set prefetch: { ttl: 1 } since each time my users return to the page, there is a high likelyhood that the cache is stale due to the nature of our dashboard and changing data. |
A method for clearing the dataset cache or changing its context from page level to element level would be useful. For larger/long running applications, the page-level cache behavior can be unexpected and undesirable. Providing away to override this, or at least programmatically clear the cache on demand would be helpful. For more justification please see my comment at the bottom of issue #41.
The text was updated successfully, but these errors were encountered: