grape-entity icon indicating copy to clipboard operation
grape-entity copied to clipboard

Cache Layer

Open aaronchi opened this issue 8 years ago • 3 comments

Are there any plans to add a caching layer to grape-entity?

active_model_serializers has this functionality (https://github.com/rails-api/active_model_serializers#caching) and I am looking into how this can be added to grape-entities.

aaronchi avatar Jul 31 '15 18:07 aaronchi

I thought about implementing a cache layer. It would be easy to come up with a proper DSL for this but there are some design problems:

  • how to plug a cache implementation? It would be good to abstract from something like Rails.cache. Well, I think it's solvable.
  • how to handle conditionals (:if, :unless)?
  • how to handle projections (:only, :except)?
  • there is something common in projections and conditionals: they both depend on options passed to presenter so result depends not only on object but on options too.

So it's not an easy task, I think.

marshall-lee avatar Jul 31 '15 18:07 marshall-lee

Having the same problem as well, we definitely need caching support or we'll need to drop Grape::Entity.

Why not use the options and projections in the hash key as well?

eidge avatar Oct 21 '15 14:10 eidge

So, what about cache? It's been over 3 years...(

nikitaserduk avatar Feb 10 '21 15:02 nikitaserduk