Skip to content
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

Add documentation for using a cache #66

Open
julianhirt opened this issue Nov 6, 2017 · 6 comments
Open

Add documentation for using a cache #66

julianhirt opened this issue Nov 6, 2017 · 6 comments

Comments

@julianhirt
Copy link

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!

@beauby
Copy link
Member

beauby commented Nov 16, 2017

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).

@samnang
Copy link

samnang commented Dec 20, 2017

@beauby I couldn't find any doc on how to setup it with rails. I have few questions:

  1. How do I setup to integrate with Rails.cache?
  2. 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?
  3. Do I have to always override cache key for each serializer or there is some default cache key?
  4. 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?

@julianhirt
Copy link
Author

Any updates on this?

@ssalzberg
Copy link

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):

@batdevis
Copy link

batdevis commented Oct 30, 2018

same for me, adding

  config.jsonapi_cache = lambda {
    Rails.cache
  }

to the initializer

@mbobin
Copy link

mbobin commented Nov 19, 2018

The error is fixed with this commit jsonapi-rb/jsonapi-renderer@f154799, but it was not released. ☹️

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

No branches or pull requests

6 participants