-
Notifications
You must be signed in to change notification settings - Fork 174
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
cache_index missing support to fetch by multiple sets of values #356
Comments
Narrowed the cause of issue. The method fetch_by_{field} works correctly for a single value. For an array, it hashes the entire array for searching in backend. A miss does not throw error because the fallback goes to Active Record which interprets input as array and behaves accordingly. A fix for this would be that the method "fetch_by_{field}" should handle the case where the input is a collection. Alternatively, there can be a separate method "fetch_multi_by_{field}". |
Perhaps what you want is a |
Thank you for the response. Yes, as I mentioned, "fetch_multi_by_#{field}" suits my case perfectly. If this changes is planned, would you know if there is any expected timeline by when this might be available? |
I don't have a timeline, but it is something that we care about since active record associations couple parts of our codebase that we want to decouple, but we still need a way to load the associated data in a decoupled way using |
@dylanahsmith hello ... were there any updates on this? |
Sorry for the delay. I've pushed a cache-index-fetch-multi branch and did some basic testing in a rails console. I still need to add some tests to the test suite for it, but you can try it out in the meantime. So a query like A |
Cool. Thank you for making the changes. |
Fixed by #368 |
Hello,
We're using IdentityCache in our rails model, something like this:
We're then using this to fetch a list of products, like this:
However, lately we've been seeing some strange behaviour with the results. Some items are not fetched from cache when keys are provided in a specific order. For example, below is from our production server:
In both the cases, the keys are same but in different order. This is repeatable, i.e. the result is same when these queries are repeated.
Do the keys need to be in any specific order for this to work correctly?
Any idea on how to fix this? Thanks in advance.
The text was updated successfully, but these errors were encountered: