Skip to content

Conversation

@Stanislav-Lapata
Copy link

This PR adds configuration

OjSerializers.configure do |config|
  config.cache = SomeCacheModule.new
end

and adds cache_options

class SomeSerializer < Oj::Serializer
  attributes :id, :name
end

class CachedSomeSerializer < SomeSerializer
  cached(cache_key: ->(object) { object.id }, options: { expires_id: 1.minute, ... }) # args are optional 
  # or
  cached_with_key ->(object) { object.id }
  # or
  cached_with_options expires_in: 1.minute
end

PR also has breaking changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant