grape-entity
grape-entity copied to clipboard
Cache Layer
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.
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.
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?
So, what about cache? It's been over 3 years...(