Class: WCC::Contentful::Store::LazyCacheStore::Query::IncludesWrapper

Inherits:
Struct
  • Object
show all
Defined in:
lib/wcc/contentful/store/lazy_cache_store.rb

Instance Method Summary collapse

Instance Method Details

#[](id) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/wcc/contentful/store/lazy_cache_store.rb', line 145

def [](id)
  return unless item = response.includes[id]

  prev = cache.read(id)
  unless (prev_rev = prev&.dig('sys', 'revision')) &&
      (next_rev = item.dig('sys', 'revision')) &&
      next_rev < prev_rev

    cache.write(id, item)
  end

  item
end