diff --git a/.travis.yml b/.travis.yml index 8cb26c8e6..6031591f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ rvm: jdk: - oraclejdk8 -install: bundle install --path=vendor/bundle --retry=3 --jobs=3 +install: bundle install --path=vendor/bundle --retry=3 --jobs=3 --without bench cache: directories: - vendor/bundle diff --git a/Gemfile b/Gemfile index 35557ef05..cbadf9380 100644 --- a/Gemfile +++ b/Gemfile @@ -39,6 +39,11 @@ gem 'tzinfo-data', platforms: (@windows_platforms + [:jruby]) group :bench do # https://github.com/rails-api/active_model_serializers/commit/cb4459580a6f4f37f629bf3185a5224c8624ca76 gem 'benchmark-ips', require: false, group: :development + gem 'oj' + gem 'oj_mimic_json' + gem 'redis', require: false + gem 'readthis', require: false + gem 'hiredis', require: false end group :test do diff --git a/test/benchmark/app.rb b/test/benchmark/app.rb index bc0d3689a..bae3e2982 100644 --- a/test/benchmark/app.rb +++ b/test/benchmark/app.rb @@ -36,7 +36,19 @@ class BenchmarkApp < Rails::Application config.cache_classes = true # CONFIG: CACHE_ON={on,off} config.action_controller.perform_caching = ENV['CACHE_ON'] != 'off' - config.action_controller.cache_store = ActiveSupport::Cache.lookup_store(:memory_store) + # config.action_controller.cache_store = ActiveSupport::Cache.lookup_store(:memory_store) + require 'redis' + require 'readthis' + require 'oj' + Readthis.serializers << ::Oj + + ENV['REDIS_URL'] = 'redis://localhost:6379/5' + config.action_controller.cache_store = :readthis_store, { + expires_in: 2.weeks.to_i, + marshal: ::Oj, + namespace: 'cache', + redis: { url: ENV.fetch('REDIS_URL'), driver: :hiredis } + } config.active_support.test_order = :random config.secret_token = 'S' * 30 diff --git a/test/benchmark/fixtures.rb b/test/benchmark/fixtures.rb index c91e102d4..8bf11b511 100644 --- a/test/benchmark/fixtures.rb +++ b/test/benchmark/fixtures.rb @@ -48,13 +48,13 @@ class CachingHasOneRelationshipSerializer < HasOneRelationshipSerializer Rails.configuration.serializers << CachingHasOneRelationshipSerializer class CachingHasManyRelationshipSerializer < HasManyRelationshipSerializer - cache expires_in: 1.day, skip_digest: true + cache expires_in: 1.day.to_i, skip_digest: true end Rails.configuration.serializers << CachingHasManyRelationshipSerializer # see https://github.com/rails-api/active_model_serializers/pull/1690/commits/68715b8f99bc29677e8a47bb3f305f23c077024b#r60344532 class CachingPrimaryResourceSerializer < ActiveModel::Serializer - cache key: 'primary_resource', expires_in: 0.1, skip_digest: true + cache key: 'primary_resource', expires_in: 1.day.to_i, skip_digest: true attributes :id, :title, :body @@ -89,7 +89,7 @@ class FragmentCachingHasManyRelationshipSerializer < HasManyRelationshipSerializ # see https://github.com/rails-api/active_model_serializers/pull/1690/commits/68715b8f99bc29677e8a47bb3f305f23c077024b#r60344532 class FragmentCachingPrimaryResourceSerializer < ActiveModel::Serializer - cache key: 'primary_resource', expires_in: 0.1, skip_digest: true + cache key: 'primary_resource', expires_in: 1.day.to_i, skip_digest: true attributes :id, :title, :body