Method: Scrivito::Workspace#cache_key

Defined in:
app/cms/scrivito/workspace.rb

#cache_keyString

This method provides a string that can be used as part of a cache key. It changes whenever any content (Obj or Widget) changes. Due to this, caches using the cache_key are invalidated whenever a CMS object in the working copy has been changed.

Scrivito provides the scrivito_cache method which integrates the cache_key with Rails’ fragment caching. You might want to check whether scrivito_cache satisfies your needs before implementing your own solution.

Returns:

  • (String)

    A string that changes whenever the content of the working copy changes.



177
178
179
# File 'app/cms/scrivito/workspace.rb', line 177

def cache_key
  @cache_key ||= Digest::SHA1.hexdigest("#{id}|#{content_state_id}")
end