Skip to content
This repository was archived by the owner on Oct 26, 2022. It is now read-only.

Is there any functionality built in that invalidates/updates the cache upon updates of a field? #63

Open
Frederik-Baetens opened this issue Sep 13, 2019 · 3 comments
Assignees

Comments

@Frederik-Baetens
Copy link

Frederik-Baetens commented Sep 13, 2019

I noticed in testing that the cache sometimes automatically gets updated after insertions, but i don't know when the field in the cache gets updated, and when it doesn't.

For example, doing just puts seems to get me the old, cached value, but running inspect seems to give an updated value?

puts Rails.cache.fetch("GraphQL::Cache:Query:restaurants:ids:#{de_moete.id}").inspect doesn't seem to cache the value, but without the inspect it does seem to get cached?

@thebadmonkeydev
Copy link
Contributor

@Frederik-Baetens SOrry for the long delay in responding here. By default the gem will attempt to use cache_key_with_version or cache_key on the object. In a Rails environment this corresponds to the ActiveRecord implementations of these methods. As to why inspect has an effect on the caching behavior...I have no idea. I will look into why that may be the case. My gut says that fetch is likely not returning the flat value but some kind of wrapper 🤷‍♂️

Can you update here with the versions you are using for Rails, graphql-ruby, and graphql-cache?

@thebadmonkeydev thebadmonkeydev self-assigned this Oct 22, 2019
@Frederik-Baetens
Copy link
Author

graphql-cache (0.6.0)
rails (5.1.7)
graphql (1.9.4)
ruby 2.6.3p62

Sorry for the late response, we aren't really looking into caching anymore, because we realized that our heaviest queries can't be cached anyways. But i do wish you good luck in solving this issue.

Maybe the other people that have liked my issue can provide you with some more context on exactly what they were doing when they had this issue.

@Frederik-Baetens
Copy link
Author

Frederik-Baetens commented Nov 7, 2019

i did see something in the rails 6.0.1 release that seems very relevant to this:

Fixed that mutating a value returned by a memory cache store would unexpectedly change the cached value.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants