You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, this is a great gem! I have enjoyed working with it.
I started caching my serializer using the cached macro. As I understand from the documentation, that would use the cache_key on the resource.
It does cache the first time I serialize the resource. Then I updated the resource and serialized it again. The second serialization uses the cached JSON, even though the resource has been updated.
Thanks,
Emil
The text was updated successfully, but these errors were encountered:
Caching uses "cache_key" by default and not "cache_key_with_version" that includes the updated_at hash. That is why it behaves like this.
Example to solve this :
class VoteSerializer < Oj::Serializer
cached_with_key ->(object) { object.cache_key_with_version }
attributes :id, :voteable_id, :voteable_type, :user_id
belongs_to :author
end
Hey 👋🏼
First off, this is a great gem! I have enjoyed working with it.
I started caching my serializer using the
cached
macro. As I understand from the documentation, that would use thecache_key
on the resource.It does cache the first time I serialize the resource. Then I updated the resource and serialized it again. The second serialization uses the cached JSON, even though the resource has been updated.
Thanks,
Emil
The text was updated successfully, but these errors were encountered: