Open gburgett opened 5 years ago
Currently the result of a Page.find_all is a lazy enumerable. If we rework this to be more of a "Relation" type object, we could concievably add cache keys to it.
Page.find_all
pages = Pages.find_all Rails.cache.fetch(pages.cache_key, version: pages.cache_version) { pages.to_a }
This would work by executing a query to the CDN to take the top 1 entry ordered by updatedAt descending. That updatedAt would then become the cache_version. documentation here: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/order
updatedAt
cache_version
This could also be a good solution to the problem of find_by caching: #18
What does rails do when you provide a collection to the fresh_when method? We should take a cue from them on this topic.
fresh_when
Currently the result of a
Page.find_all
is a lazy enumerable. If we rework this to be more of a "Relation" type object, we could concievably add cache keys to it.This would work by executing a query to the CDN to take the top 1 entry ordered by
updatedAt
descending. ThatupdatedAt
would then become thecache_version
. documentation here: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/orderThis could also be a good solution to the problem of find_by caching: #18