I want to cache the result of a query in ember-data. (findQuery
)
To make it clear: I don't want to cache the entire models; just what models are the result of the query. Where is the right place for this?
I was thinking about implementing this in the adapter and cache the result of the AJAX call, but I don't think this is a good solution since I don't wanna override the loaded and maybe newer and/or modified model data.
I don't thinks its possible to just return a list of ID's, and to manipulate the adapter and the serializer for this simple use-case seems to be messy!
Actually I don't want that findQuery
is called for specific types of querys. Like the behavior of findAll
. Nice would be something like a queryShouldBeCached
hook.
Is there a good Solution for this?
setupController
anddeactivate
hooks of the route, where I grab a reference to the controller and cache full records there. In my case I destroy them when I transition out, so you'd have to consider how to trigger a deferred cleanup. I believe it belongs in the route/controller, rather than the adapter which is more of a abstract/global thing. This way it's contained for the specific function (search). – aceofspades