performance/cache_runner.rb in identity_cache-0.0.7 vs performance/cache_runner.rb in identity_cache-0.1.0

- old
+ new

@@ -14,12 +14,15 @@ $mysql_port = 3306 end require File.dirname(__FILE__) + '/../test/helpers/active_record_objects' require File.dirname(__FILE__) + '/../test/helpers/database_connection' -require File.dirname(__FILE__) + '/../test/helpers/cache' +IdentityCache.logger = Logger.new(nil) +IdentityCache.cache_backend = ActiveSupport::Cache::MemcachedStore.new("localhost:#{$memcached_port}") + + def create_record(id) Item.new(id) end def database_ready(count) @@ -83,11 +86,11 @@ CACHE_RUNNERS = [] class FindRunner < CacheRunner def run (1..@count).each do |i| - ::Item.find(i, :include => [:associated, {:associated_records => :deeply_associated_records}]) + ::Item.includes(:associated, {:associated_records => :deeply_associated_records}).find(i) end end end CACHE_RUNNERS << FindRunner @@ -135,11 +138,11 @@ class NormalizedRunner < CacheRunner def setup_models super Item.cache_has_one :associated # :embed => false isn't supported - Item.cache_has_many :associated_records, :embed => false - AssociatedRecord.cache_has_many :deeply_associated_records, :embed => false + Item.cache_has_many :associated_records, :embed => :ids + AssociatedRecord.cache_has_many :deeply_associated_records, :embed => :ids end def run (1..@count).each do |i| rec = ::Item.fetch(i)