Is there any functionality built in that invalidates/updates the cache upon updates of a field?
Frederik-Baetens opened this issue · 3 comments
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?
@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?
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.
i did see something in the rails 6.0.1 release that seems very relevant to this: