oj_serializers
oj_serializers copied to clipboard
add configuration and cache options
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