Comments (9)
Hey @keithm-thompson,
They serve different purposes, so you can safely use both together. The first is for avoiding recreating entry objects if they are reused somewhere along the hydration process, the second one is to limit the amount of chaining on long chains of unique objects (if you enable reuse_entries
).
Cheers
from contentful_rails.
Hey @raybradley,
Looks like you may have multiple circular references. To limit them, either enable reuse_entries
or limit the maximum include resolution depth with max_include_resolution_depth
, I'd suggest to your maximum include level + 1.
Both of this options are available through the options
in the configuration block.
Cheers
from contentful_rails.
I'm afraid I'm missing something here. Given this config block:
ContentfulRails.configure do |config|
config.access_token = ENV['CONTENTFUL_ACCESS_TOKEN']
config.preview_access_token = ENV['CONTENTFUL_PREVIEW_ACCESS_TOKEN']
config.space = ENV['CONTENTFUL_SPACE_ID']
config.default_locale = "en-US"
config.max_include_resolution_depth = 2
end
...the app complains thusly:
undefined method `max_include_resolution_depth=' for #<ContentfulRails::Configuration:0x00007f82c8b59a80>
Ideas? Is the option documented as part of the contentful_rails gem and I'm missing it?
from contentful_rails.
ContentfulRails.configure do |config|
config.access_token = ENV['CONTENTFUL_ACCESS_TOKEN']
config.preview_access_token = ENV['CONTENTFUL_PREVIEW_ACCESS_TOKEN']
config.space = ENV['CONTENTFUL_SPACE_ID']
config.default_locale = "en-US"
config.contentful_options = {
max_include_resolution_depth: 2
}
end
I personally recommend enabling reuse_entries
instead.
from contentful_rails.
Thanks @shaug ... that was non-obvious :)
Why do you recommend reuse_entries
over max_include_resolution_depth
?
from contentful_rails.
Hey @raybradley,
It depends, reuse_entries will be more performant and will take less memory, but this is at the cost of disabling caching capabilities when having circular references, as it will generate a stack level too deep error.
Reducing the maximum include resolution limit, while a bit less perfomant when having circular references, has the same performance and uses the same amount of memories when dealing with unique objects. When having circular references, as the referenced objects do not point to the same address and are actually limited in depth, you can safely use caching mechanisms without being afraid of getting stack too deep exceptions.
Hope that explains it a little bit better.
Cheers
from contentful_rails.
Thanks for the suggestions, but unfortunately it's still happening. Anything further you all would recommend to troubleshoot or profile the calls I'm making?
from contentful_rails.
Hey @raybradley,
I'd suggest using something like NewRelic to check what's the memory bottleneck you're having. So that we can have a better idea of what may be the cause of your issue.
In the meantime, I'd suggest limiting your request size to an amount you can handle with the memory constraints you have. You can do so by using the limit
query operator, which defaults to 100 (same if omitted as you currently have). And start playing both with that and with the include
operator (if you're using version 1.0 of contentful_model
it will default to the nesting level of your models, though this nesting has to be explicitly declared with has_one
, has_many
, etc relationships - maximum of 10).
Hope this helps,
Cheers
from contentful_rails.
Hey @dlitvakb,
Looks like adding both reuse_entries
and max_include_resolution_depth
did the trick for us. Is there any reason why we should avoid having both flags set in the config options?
Thanks!
from contentful_rails.
Related Issues (20)
- Concern with `eager_load!` HOT 14
- Subclassing MarkdownRenderer HOT 5
- Missing attr_writer for attributes with nil values HOT 3
- #delete_matched not supported by all ActiveSupport cache types HOT 2
- alias_method_chain call in timestamps.rb causes deprecation warning HOT 4
- this thing work? HOT 10
- Rails 5 support? HOT 1
- enable caching support HOT 7
- Can't load gem without ActiveRecord HOT 6
- Webhooks Rails 5 HOT 6
- Webhooks fail in Rails 5.1 HOT 2
- Content types caching blowing up VCR on CI HOT 1
- Release webhooks fix? HOT 1
- Load error HOT 5
- Support Contentful Model 1.0 HOT 2
- Webhook Engine does not provide the /debug route as expected HOT 1
- How do you perform the russian nesting doll cache?
- "Only Redis glob strings are supported: " on unpublish when using redis as cache store
- Eager load in a to_prepare block
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from contentful_rails.