jsonapi-rails icon indicating copy to clipboard operation
jsonapi-rails copied to clipboard

Add documentation for using a cache

Open julianhirt opened this issue 7 years ago • 6 comments

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!

julianhirt avatar Nov 06 '17 22:11 julianhirt

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 avatar Nov 16 '17 11:11 beauby

@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?

samnang avatar Dec 20 '17 17:12 samnang

Any updates on this?

julianhirt avatar Jan 23 '18 15:01 julianhirt

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

ssalzberg avatar May 17 '18 17:05 ssalzberg

same for me, adding

  config.jsonapi_cache = lambda {
    Rails.cache
  }

to the initializer

batdevis avatar Oct 30 '18 13:10 batdevis

The error is fixed with this commit https://github.com/jsonapi-rb/jsonapi-renderer/commit/f154799ff0d0ea8132b4e7acd632060cb0f7d22c, but it was not released. ☹️

mbobin avatar Nov 19 '18 14:11 mbobin