class ActiveModelSerializers::CachedSerializer

def object_cache_key

Pass the `key` option to the `cache` declaration or override this method to customize the cache key
Use object's cache_key if available, else derive a key from the object
def object_cache_key
  if @cached_serializer.object.respond_to?(:cache_key)
    @cached_serializer.object.cache_key
  elsif (cache_key = (@klass._cache_key || @klass._cache_options[:key]))
    object_time_safe = @cached_serializer.object.updated_at
    object_time_safe = object_time_safe.strftime('%Y%m%d%H%M%S%9N') if object_time_safe.respond_to?(:strftime)
    "#{cache_key}/#{@cached_serializer.object.id}-#{object_time_safe}"
  else
    fail UndefinedCacheKey, "#{@cached_serializer.object.class} must define #cache_key, or the 'key:' option must be passed into '#{@klass}.cache'"
  end
end