jsonapi-rails
jsonapi-rails copied to clipboard
Add documentation for using a cache
Hi there, I do find the default values for jsonapi_cache and default initializers, but is it possible to add some documentation? I have a very static json and it would be awesome to have it cached somewhere. Thanks in advance!
Hi @julianhirt – it is planned but I'm rather busy at the moment so can't really give an ETA on the docs. In the meantime, feel free to ask any question you may have (either here or on gitter).
@beauby I couldn't find any doc on how to setup it with rails. I have few questions:
- How do I setup to integrate with
Rails.cache
? - When I want to have cache functionality, do we pass some options in
controller#render jsonapi: ...
or I just define some option in my serializers? - Do I have to always override cache key for each serializer or there is some default cache key?
- When I render a resource that includes relationships, are nested relationships required to override cache key, or we just only define in top/root resource only?
Any updates on this?
Following up on this as well... I'm trying to implement caching by adding the "cache: Rails.cache" option to "render jsonapi: ...", but seeing this error:
NoMethodError (undefined method `as_jsonapi' for nil:NilClass Did you mean? as_json):
same for me, adding
config.jsonapi_cache = lambda {
Rails.cache
}
to the initializer
The error is fixed with this commit https://github.com/jsonapi-rb/jsonapi-renderer/commit/f154799ff0d0ea8132b4e7acd632060cb0f7d22c, but it was not released. ☹️