xunch 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/lib/xunch.rb +25 -0
 - data/lib/xunch/cache/cache.rb +88 -0
 - data/lib/xunch/cache/cache_builder.rb +68 -0
 - data/lib/xunch/cache/field_object_cache.rb +120 -0
 - data/lib/xunch/cache/list_field_object_cache.rb +63 -0
 - data/lib/xunch/cache/list_object_cache.rb +59 -0
 - data/lib/xunch/cache/object_cache.rb +63 -0
 - data/lib/xunch/codec/codec.rb +31 -0
 - data/lib/xunch/codec/hash_codec.rb +98 -0
 - data/lib/xunch/codec/json_codec.rb +81 -0
 - data/lib/xunch/shard/redis.rb +270 -0
 - data/lib/xunch/shard/shard_info.rb +37 -0
 - data/lib/xunch/shard/shard_redis.rb +267 -0
 - data/lib/xunch/shard/sharded.rb +50 -0
 - data/lib/xunch/utils/exceptions.rb +11 -0
 - data/lib/xunch/utils/nginx_cache_helper.rb +52 -0
 - data/lib/xunch/utils/rb_tree.rb +634 -0
 - data/lib/xunch/utils/rb_tree_node.rb +67 -0
 - data/lib/xunch/utils/types.rb +8 -0
 - data/lib/xunch/utils/utils.rb +24 -0
 - data/test/benchmark_test.rb +68 -0
 - data/test/cache_builder_test.rb +28 -0
 - data/test/cache_object.rb +120 -0
 - data/test/consistency_hash_test.rb +31 -0
 - data/test/field_object_cache_test.rb +430 -0
 - data/test/hash_codec_test.rb +57 -0
 - data/test/json_codec_test.rb +57 -0
 - data/test/list_field_object_cache_test.rb +211 -0
 - data/test/list_object_cache_test.rb +211 -0
 - data/test/nginx_cache_helper_test.rb +45 -0
 - data/test/object_cache_test.rb +322 -0
 - data/test/rb_tree_test.rb +48 -0
 - data/test/redis_benchmark_test.rb +54 -0
 - data/test/redis_test.rb +58 -0
 - data/test/running_test.rb +212 -0
 - data/test/test.rb +176 -0
 - data/test/track_record_origin.rb +58 -0
 - metadata +125 -0
 
| 
         @@ -0,0 +1,67 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # :nodoc: namespace
         
     | 
| 
      
 2 
     | 
    
         
            +
            module Xunch
         
     | 
| 
      
 3 
     | 
    
         
            +
              class RBTree
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # A node in the red-black tree.
         
     | 
| 
      
 6 
     | 
    
         
            +
            #
         
     | 
| 
      
 7 
     | 
    
         
            +
            # Nodes should only be manipulated directly by the RedBlackTree class.
         
     | 
| 
      
 8 
     | 
    
         
            +
                class Node
         
     | 
| 
      
 9 
     | 
    
         
            +
                  attr_accessor :key
         
     | 
| 
      
 10 
     | 
    
         
            +
                  attr_accessor :value
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  attr_accessor :color
         
     | 
| 
      
 13 
     | 
    
         
            +
                  attr_accessor :left
         
     | 
| 
      
 14 
     | 
    
         
            +
                  attr_accessor :right
         
     | 
| 
      
 15 
     | 
    
         
            +
                  attr_accessor :parent
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  # Creates a new node.
         
     | 
| 
      
 18 
     | 
    
         
            +
                  #
         
     | 
| 
      
 19 
     | 
    
         
            +
                  # New tree nodes are red by default.
         
     | 
| 
      
 20 
     | 
    
         
            +
                  def initialize(key, value, parent)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    @color = :black
         
     | 
| 
      
 22 
     | 
    
         
            +
                    @key = key
         
     | 
| 
      
 23 
     | 
    
         
            +
                    @value = value
         
     | 
| 
      
 24 
     | 
    
         
            +
                    @parent = parent
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  # node to string
         
     | 
| 
      
 28 
     | 
    
         
            +
                  def to_s
         
     | 
| 
      
 29 
     | 
    
         
            +
                    "#{@key}=#{@value},#{@color}"
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
                  
         
     | 
| 
      
 32 
     | 
    
         
            +
                  def inspect
         
     | 
| 
      
 33 
     | 
    
         
            +
                    "#{@key}=#{@value},#{@color}"
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
      
 35 
     | 
    
         
            +
                  
         
     | 
| 
      
 36 
     | 
    
         
            +
                  # True for black nodes.
         
     | 
| 
      
 37 
     | 
    
         
            +
                  def black?
         
     | 
| 
      
 38 
     | 
    
         
            +
                    @color == :black
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                  # True for red nodes.
         
     | 
| 
      
 42 
     | 
    
         
            +
                  def red?
         
     | 
| 
      
 43 
     | 
    
         
            +
                    @color == :red
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                end   # class RBTree::Node
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                class ImmutableNode
         
     | 
| 
      
 49 
     | 
    
         
            +
                  attr_reader :key
         
     | 
| 
      
 50 
     | 
    
         
            +
                  attr_reader :value
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                  def initialize(key, value)
         
     | 
| 
      
 53 
     | 
    
         
            +
                    @key = key
         
     | 
| 
      
 54 
     | 
    
         
            +
                    @value = value
         
     | 
| 
      
 55 
     | 
    
         
            +
                  end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                  def inspect
         
     | 
| 
      
 58 
     | 
    
         
            +
                    "#{@key}=#{@value}"
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  def to_s
         
     | 
| 
      
 62 
     | 
    
         
            +
                    "#{@key}=#{@value}"
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                end   # class RBTree::ImmutableNode
         
     | 
| 
      
 66 
     | 
    
         
            +
              end   # namespace RBTree
         
     | 
| 
      
 67 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Xunch
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Utils
         
     | 
| 
      
 3 
     | 
    
         
            +
                def self.format_field(field)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  array = field.split("_")
         
     | 
| 
      
 5 
     | 
    
         
            +
                  field_mod = array[0]
         
     | 
| 
      
 6 
     | 
    
         
            +
                  for i in 1 .. array.length-1 do
         
     | 
| 
      
 7 
     | 
    
         
            +
                    field_mod << array[i].capitalize  
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
                  field_mod.freeze
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def self.format_fields(fields)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  formatted_fields = []
         
     | 
| 
      
 14 
     | 
    
         
            +
                  fields.each{ |field|
         
     | 
| 
      
 15 
     | 
    
         
            +
                    if field.strip.empty?
         
     | 
| 
      
 16 
     | 
    
         
            +
                      raise XunchError.new("can't format empty string")
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
                    field_mod = format_field(field.strip)
         
     | 
| 
      
 19 
     | 
    
         
            +
                    formatted_fields.push field_mod
         
     | 
| 
      
 20 
     | 
    
         
            +
                  }
         
     | 
| 
      
 21 
     | 
    
         
            +
                  formatted_fields
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,68 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $:.unshift File.expand_path("../../lib", __FILE__)
         
     | 
| 
      
 2 
     | 
    
         
            +
            $:.unshift File.expand_path("../../test", __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "test/unit"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "xunch"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'yaml'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'cache_object'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'bigdecimal'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'hessian2'
         
     | 
| 
      
 9 
     | 
    
         
            +
            require 'track_record_origin'
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            DEFAULTS = {
         
     | 
| 
      
 12 
     | 
    
         
            +
                  :size => 1,
         
     | 
| 
      
 13 
     | 
    
         
            +
                  :timeout => nil,
         
     | 
| 
      
 14 
     | 
    
         
            +
                  :driver => :hiredis,
         
     | 
| 
      
 15 
     | 
    
         
            +
                  :host => '192.168.1.174',
         
     | 
| 
      
 16 
     | 
    
         
            +
                  :port=>6379,
         
     | 
| 
      
 17 
     | 
    
         
            +
                  :password=>'jredis123456',
         
     | 
| 
      
 18 
     | 
    
         
            +
                  :db=>14,
         
     | 
| 
      
 19 
     | 
    
         
            +
                  :timeout=>6
         
     | 
| 
      
 20 
     | 
    
         
            +
                }
         
     | 
| 
      
 21 
     | 
    
         
            +
            TrackInRecordStruct = Struct.new(:id, :track_id, :uid, :op_type, :nickname, :avatar_path, :is_v, :is_public, :is_publish, :user_source, :category_id, :title, :intro, :tags, :cover_path, :duration, :download_path, :play_path, :play_path_128, :play_path_64, :play_path_32, :singer, :singer_category, :author, :composer, :arrangement, :post_production, :lyric, :lyric_path, :language, :resinger, :announcer, :access_password, :allow_download, :allow_comment, :is_crawler, :inet_aton_ip, :upload_source, :longitude, :latitude, :album_id, :album_title, :album_cover_path, :transcode_state, :created_at, :updated_at, :rich_intro, :comment_content, :comment_id, :track_upload_source, :is_pick, :track_uid, :short_intro, :is_deleted, :dig_status, :approved_at, :mp3size, :mp3size_32, :mp3size_64, :upload_id, :waveform, :extra_tags, :ignore_tags, :music_category, :order_num, :source_url, :status, :human_category_id, :explore_height)
         
     | 
| 
      
 22 
     | 
    
         
            +
            class ObjectCacheTest < Test::Unit::TestCase
         
     | 
| 
      
 23 
     | 
    
         
            +
              include Test::Unit::Assertions
         
     | 
| 
      
 24 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 25 
     | 
    
         
            +
                super
         
     | 
| 
      
 26 
     | 
    
         
            +
                root = File.expand_path("../..", __FILE__)
         
     | 
| 
      
 27 
     | 
    
         
            +
                file = File.join(root, 'test/xunch.yaml')
         
     | 
| 
      
 28 
     | 
    
         
            +
                caches = Xunch::CacheBuilder.build(file)
         
     | 
| 
      
 29 
     | 
    
         
            +
                @object_cache = caches["track"]
         
     | 
| 
      
 30 
     | 
    
         
            +
                puts "setup"
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              def test_benchmark
         
     | 
| 
      
 34 
     | 
    
         
            +
                redis = Redis.new(DEFAULTS)
         
     | 
| 
      
 35 
     | 
    
         
            +
                cache_object = TrackRecordOrigin.find(1)
         
     | 
| 
      
 36 
     | 
    
         
            +
                assert_equal('OK',@object_cache.put(cache_object))
         
     | 
| 
      
 37 
     | 
    
         
            +
                # puts "object: #{@object_cache.get(1).inspect}"
         
     | 
| 
      
 38 
     | 
    
         
            +
                object = nil
         
     | 
| 
      
 39 
     | 
    
         
            +
                s1 = Time.now
         
     | 
| 
      
 40 
     | 
    
         
            +
                2.times do
         
     | 
| 
      
 41 
     | 
    
         
            +
                  object = @object_cache.get(1)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  # data = redis.get("track_1_1")
         
     | 
| 
      
 43 
     | 
    
         
            +
                end
         
     | 
| 
      
 44 
     | 
    
         
            +
                puts object.inspect
         
     | 
| 
      
 45 
     | 
    
         
            +
                s2 = Time.now
         
     | 
| 
      
 46 
     | 
    
         
            +
                puts s2-s1
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                
         
     | 
| 
      
 49 
     | 
    
         
            +
                redis.set("track_1_2", Hessian2.write(Hessian2::StructWrapper.new(TrackInRecordStruct, cache_object)))
         
     | 
| 
      
 50 
     | 
    
         
            +
                redis.pexpire("track_1_2",100000)
         
     | 
| 
      
 51 
     | 
    
         
            +
                object2 = nil
         
     | 
| 
      
 52 
     | 
    
         
            +
                s1 = Time.now
         
     | 
| 
      
 53 
     | 
    
         
            +
                2.times do
         
     | 
| 
      
 54 
     | 
    
         
            +
                  data = redis.get("track_1_2")
         
     | 
| 
      
 55 
     | 
    
         
            +
                  object2 = Hessian2.parse(data, TrackInRecordStruct)
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
                s2 = Time.now
         
     | 
| 
      
 58 
     | 
    
         
            +
                puts object2.inspect
         
     | 
| 
      
 59 
     | 
    
         
            +
                puts s2-s1
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 64 
     | 
    
         
            +
                super
         
     | 
| 
      
 65 
     | 
    
         
            +
                puts "teardown"
         
     | 
| 
      
 66 
     | 
    
         
            +
              end
         
     | 
| 
      
 67 
     | 
    
         
            +
            end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $:.unshift File.expand_path("../../lib", __FILE__)
         
     | 
| 
      
 2 
     | 
    
         
            +
            $:.unshift File.expand_path("../../test", __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "test/unit"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'xunch'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'track_record_origin'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            class CacheBuilderTest < Test::Unit::TestCase
         
     | 
| 
      
 8 
     | 
    
         
            +
              include Test::Unit::Assertions
         
     | 
| 
      
 9 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 10 
     | 
    
         
            +
                super
         
     | 
| 
      
 11 
     | 
    
         
            +
                puts "setup"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              def test_build
         
     | 
| 
      
 15 
     | 
    
         
            +
                root = File.expand_path("../..", __FILE__)
         
     | 
| 
      
 16 
     | 
    
         
            +
                file = File.join(root, 'test/xunch.yaml')
         
     | 
| 
      
 17 
     | 
    
         
            +
                caches = Xunch::CacheBuilder.build(file)
         
     | 
| 
      
 18 
     | 
    
         
            +
                caches.each { |key ,value|
         
     | 
| 
      
 19 
     | 
    
         
            +
                  puts key
         
     | 
| 
      
 20 
     | 
    
         
            +
                  puts value
         
     | 
| 
      
 21 
     | 
    
         
            +
                }
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 25 
     | 
    
         
            +
                super
         
     | 
| 
      
 26 
     | 
    
         
            +
                puts "teardown"
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,120 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'active_record'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'bigdecimal'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'mysql2'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class CacheObject < ActiveRecord::Base
         
     | 
| 
      
 6 
     | 
    
         
            +
              self.table_name = 'tb_xunch'
         
     | 
| 
      
 7 
     | 
    
         
            +
              self.primary_key = "big_num_field"
         
     | 
| 
      
 8 
     | 
    
         
            +
              conn = {
         
     | 
| 
      
 9 
     | 
    
         
            +
                :adapter => "mysql2",
         
     | 
| 
      
 10 
     | 
    
         
            +
                :encoding => "utf8",
         
     | 
| 
      
 11 
     | 
    
         
            +
                :reconnect => false,
         
     | 
| 
      
 12 
     | 
    
         
            +
                :database => "test",
         
     | 
| 
      
 13 
     | 
    
         
            +
                :username => "root",
         
     | 
| 
      
 14 
     | 
    
         
            +
                :password => "111111",
         
     | 
| 
      
 15 
     | 
    
         
            +
                :host => "127.0.0.1"
         
     | 
| 
      
 16 
     | 
    
         
            +
              }
         
     | 
| 
      
 17 
     | 
    
         
            +
              ActiveRecord::Base.establish_connection(conn)
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
              # include Xzunch::ColumnMethods
         
     | 
| 
      
 20 
     | 
    
         
            +
              # include Xunch::Converter
         
     | 
| 
      
 21 
     | 
    
         
            +
              attr_accessible :fix_num_field, :string_field, :big_num_field, :datetime_field, :float_field, :big_decimal_field
         
     | 
| 
      
 22 
     | 
    
         
            +
              # attr_type_define :time_field => :datetime, :big_decimal_field => :big_decimal
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              TYPE_MAP = {
         
     | 
| 
      
 25 
     | 
    
         
            +
                "datetime_field" =>:datetime, 
         
     | 
| 
      
 26 
     | 
    
         
            +
                "big_decimal_field" => :bigdecimal,
         
     | 
| 
      
 27 
     | 
    
         
            +
                "fix_num_field" => :fixnum,
         
     | 
| 
      
 28 
     | 
    
         
            +
                "float_field" => :float,
         
     | 
| 
      
 29 
     | 
    
         
            +
                "big_num_field" => :bignum
         
     | 
| 
      
 30 
     | 
    
         
            +
              }
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              def to_s
         
     | 
| 
      
 33 
     | 
    
         
            +
                "{fix_num_field=>#{@fix_num_field},string_field=>#{@string_field}," << 
         
     | 
| 
      
 34 
     | 
    
         
            +
                "big_num_field=>#{@big_num_field},time_field=>#{@time_field}," << 
         
     | 
| 
      
 35 
     | 
    
         
            +
                "float_field=>#{@float_field},big_decimal_field=>#{@big_decimal_field}}"
         
     | 
| 
      
 36 
     | 
    
         
            +
                
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 40 
     | 
    
         
            +
                super
         
     | 
| 
      
 41 
     | 
    
         
            +
                # @fix_num_field = 111
         
     | 
| 
      
 42 
     | 
    
         
            +
                # @string_field = "111"
         
     | 
| 
      
 43 
     | 
    
         
            +
                # @big_num_field = 123123123123123123123123123123123
         
     | 
| 
      
 44 
     | 
    
         
            +
                # @datetime_field = DateTime.new
         
     | 
| 
      
 45 
     | 
    
         
            +
                # @float_field = 111.123213213123
         
     | 
| 
      
 46 
     | 
    
         
            +
                # @big_decimal_field = BigDecimal.new("111111111111111111111111111111234.45466689324211111111111111111")
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            # puts CacheObject.kind_of?(ActiveRecord::Base)
         
     | 
| 
      
 52 
     | 
    
         
            +
            # puts CacheObject.is_a?(ActiveRecord::Base)
         
     | 
| 
      
 53 
     | 
    
         
            +
            # puts CacheObject.ancestors
         
     | 
| 
      
 54 
     | 
    
         
            +
            # puts CacheObject.method_defined?(:_accessible_attributes)
         
     | 
| 
      
 55 
     | 
    
         
            +
            # raise ArgumentError.new("Codec class does not defined method '_accessible_attributes', maybe this klass is not a subclass of ActiveRecord::Base.") unless CacheObject.method_defined?(:_accessible_attributes)
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            # o = CacheObject.new
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            # methods = CacheObject.instance_methods()
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            # set_methods = {}
         
     | 
| 
      
 62 
     | 
    
         
            +
            # get_methods = {}
         
     | 
| 
      
 63 
     | 
    
         
            +
            # methods.each { | method |
         
     | 
| 
      
 64 
     | 
    
         
            +
            #   puts method[method.length-1] == '='
         
     | 
| 
      
 65 
     | 
    
         
            +
            #   if method[method.length-1] == '='
         
     | 
| 
      
 66 
     | 
    
         
            +
            #     set_methods[method[0,method.length-1]] = method
         
     | 
| 
      
 67 
     | 
    
         
            +
            #     get_methods[method[0,method.length-1]] = method[0,method.length-1].to_sym
         
     | 
| 
      
 68 
     | 
    
         
            +
            #   end
         
     | 
| 
      
 69 
     | 
    
         
            +
            # }
         
     | 
| 
      
 70 
     | 
    
         
            +
            # puts set_methods
         
     | 
| 
      
 71 
     | 
    
         
            +
            # puts get_methods
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            # object = CacheObject.new
         
     | 
| 
      
 74 
     | 
    
         
            +
            # start = Time.new
         
     | 
| 
      
 75 
     | 
    
         
            +
            # for i in 0 .. 10000000 do 
         
     | 
| 
      
 76 
     | 
    
         
            +
            #   object.fix_num_field = i
         
     | 
| 
      
 77 
     | 
    
         
            +
            # end
         
     | 
| 
      
 78 
     | 
    
         
            +
            # stop = Time.new
         
     | 
| 
      
 79 
     | 
    
         
            +
            # puts stop - start
         
     | 
| 
      
 80 
     | 
    
         
            +
            # start = Time.new
         
     | 
| 
      
 81 
     | 
    
         
            +
            # for i in 0 .. 10000000 do 
         
     | 
| 
      
 82 
     | 
    
         
            +
            #   object.instance_variable_set(("@" + "fix_num_field"), i)
         
     | 
| 
      
 83 
     | 
    
         
            +
            # end
         
     | 
| 
      
 84 
     | 
    
         
            +
            # stop = Time.new
         
     | 
| 
      
 85 
     | 
    
         
            +
            # puts stop - start
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
            # start = Time.new
         
     | 
| 
      
 88 
     | 
    
         
            +
            # for i in 0 .. 10000000 do 
         
     | 
| 
      
 89 
     | 
    
         
            +
            #   object.fix_num_field
         
     | 
| 
      
 90 
     | 
    
         
            +
            # end
         
     | 
| 
      
 91 
     | 
    
         
            +
            # stop = Time.new
         
     | 
| 
      
 92 
     | 
    
         
            +
            # puts stop - start
         
     | 
| 
      
 93 
     | 
    
         
            +
            # start = Time.new
         
     | 
| 
      
 94 
     | 
    
         
            +
            # for i in 0 .. 10000000 do 
         
     | 
| 
      
 95 
     | 
    
         
            +
            #   object.instance_variable_get(:@fix_num_field)
         
     | 
| 
      
 96 
     | 
    
         
            +
            # end
         
     | 
| 
      
 97 
     | 
    
         
            +
            # stop = Time.new
         
     | 
| 
      
 98 
     | 
    
         
            +
            # puts stop - start
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
            # start = Time.new
         
     | 
| 
      
 101 
     | 
    
         
            +
            # for i in 0 .. 10000000 do 
         
     | 
| 
      
 102 
     | 
    
         
            +
            #   object.send(:fix_num_field)
         
     | 
| 
      
 103 
     | 
    
         
            +
            # end
         
     | 
| 
      
 104 
     | 
    
         
            +
            # stop = Time.new
         
     | 
| 
      
 105 
     | 
    
         
            +
            # puts stop - start
         
     | 
| 
      
 106 
     | 
    
         
            +
            # start = Time.new
         
     | 
| 
      
 107 
     | 
    
         
            +
            # for i in 0 .. 10000000 do 
         
     | 
| 
      
 108 
     | 
    
         
            +
            #   object.send("fix_num_field=",i)
         
     | 
| 
      
 109 
     | 
    
         
            +
            # end
         
     | 
| 
      
 110 
     | 
    
         
            +
            # stop = Time.new
         
     | 
| 
      
 111 
     | 
    
         
            +
            # puts stop - start
         
     | 
| 
      
 112 
     | 
    
         
            +
            # set_methods = {}
         
     | 
| 
      
 113 
     | 
    
         
            +
            # get_methods = {}
         
     | 
| 
      
 114 
     | 
    
         
            +
            # CacheObject._accessible_attributes[:default].each { |attribute|
         
     | 
| 
      
 115 
     | 
    
         
            +
            #   get_methods[attribute] = attribute.to_sym
         
     | 
| 
      
 116 
     | 
    
         
            +
            #   set_methods[attribute] = (attribute + "=").to_sym
         
     | 
| 
      
 117 
     | 
    
         
            +
            # }
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
            # p set_methods
         
     | 
| 
      
 120 
     | 
    
         
            +
            # p get_methods
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "test/unit"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rbtree'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'murmurhash'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'redis'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            class ConsistencyhashTest < Test::Unit::TestCase
         
     | 
| 
      
 7 
     | 
    
         
            +
              include Test::Unit::Assertions
         
     | 
| 
      
 8 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 9 
     | 
    
         
            +
                super
         
     | 
| 
      
 10 
     | 
    
         
            +
                puts "setup"
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              def test_consistency_hash
         
     | 
| 
      
 14 
     | 
    
         
            +
                redis = Redis.new(:host => "192.168.1.174", :port => 6379, :password => "jredis123456")
         
     | 
| 
      
 15 
     | 
    
         
            +
                redis.select 10
         
     | 
| 
      
 16 
     | 
    
         
            +
                rbtree = RBTree[]
         
     | 
| 
      
 17 
     | 
    
         
            +
                rbtree[1] = redis
         
     | 
| 
      
 18 
     | 
    
         
            +
                rbtree[5] = redis
         
     | 
| 
      
 19 
     | 
    
         
            +
                rbtree[11] = redis
         
     | 
| 
      
 20 
     | 
    
         
            +
                puts rbtree[1].inspect
         
     | 
| 
      
 21 
     | 
    
         
            +
                # puts rbtree.lower_bound(1)
         
     | 
| 
      
 22 
     | 
    
         
            +
                # puts rbtree.upper_bound(2)
         
     | 
| 
      
 23 
     | 
    
         
            +
                # puts rbtree.first.class
         
     | 
| 
      
 24 
     | 
    
         
            +
                puts Murmurhash.hash2A("2")
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 28 
     | 
    
         
            +
                super
         
     | 
| 
      
 29 
     | 
    
         
            +
                puts "teardown"
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,430 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $:.unshift File.expand_path("../../lib", __FILE__)
         
     | 
| 
      
 2 
     | 
    
         
            +
            $:.unshift File.expand_path("../../test", __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "test/unit"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "xunch"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'yaml'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'track_record_origin'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'bigdecimal'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            class FieldObjectCacheTest < Test::Unit::TestCase
         
     | 
| 
      
 11 
     | 
    
         
            +
              include Test::Unit::Assertions
         
     | 
| 
      
 12 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 13 
     | 
    
         
            +
                root = File.expand_path("../..", __FILE__)
         
     | 
| 
      
 14 
     | 
    
         
            +
                file = File.join(root, 'test/xunch.yaml')
         
     | 
| 
      
 15 
     | 
    
         
            +
                caches = Xunch::CacheBuilder.build(file)
         
     | 
| 
      
 16 
     | 
    
         
            +
                @field_object_cache = caches["trackfield"]
         
     | 
| 
      
 17 
     | 
    
         
            +
                @fields = ["createdAt","updatedAt","approvedAt","isCrawler","isPublic","mp3size","longitude","trackId","playPath"]
         
     | 
| 
      
 18 
     | 
    
         
            +
                @cache_object = TrackRecordOrigin.find(1)
         
     | 
| 
      
 19 
     | 
    
         
            +
                @cache_objects = [@cache_object]
         
     | 
| 
      
 20 
     | 
    
         
            +
                @keys = [1]
         
     | 
| 
      
 21 
     | 
    
         
            +
                for i in 2 .. 100 do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  new_cache_object = TrackRecordOrigin.new
         
     | 
| 
      
 23 
     | 
    
         
            +
                  new_cache_object.track_id = @cache_object.track_id
         
     | 
| 
      
 24 
     | 
    
         
            +
                  new_cache_object.track_uid = @cache_object.track_uid
         
     | 
| 
      
 25 
     | 
    
         
            +
                  new_cache_object.track_upload_source = @cache_object.track_upload_source
         
     | 
| 
      
 26 
     | 
    
         
            +
                  new_cache_object.op_type = @cache_object.op_type
         
     | 
| 
      
 27 
     | 
    
         
            +
                  new_cache_object.is_publish = @cache_object.is_publish
         
     | 
| 
      
 28 
     | 
    
         
            +
                  new_cache_object.upload_source = @cache_object.upload_source
         
     | 
| 
      
 29 
     | 
    
         
            +
                  new_cache_object.uid = @cache_object.uid
         
     | 
| 
      
 30 
     | 
    
         
            +
                  new_cache_object.nickname = @cache_object.nickname
         
     | 
| 
      
 31 
     | 
    
         
            +
                  new_cache_object.avatar_path = @cache_object.avatar_path
         
     | 
| 
      
 32 
     | 
    
         
            +
                  new_cache_object.is_v = @cache_object.is_v
         
     | 
| 
      
 33 
     | 
    
         
            +
                  new_cache_object.human_category_id = @cache_object.human_category_id
         
     | 
| 
      
 34 
     | 
    
         
            +
                  new_cache_object.title = @cache_object.title
         
     | 
| 
      
 35 
     | 
    
         
            +
                  new_cache_object.intro = @cache_object.intro
         
     | 
| 
      
 36 
     | 
    
         
            +
                  new_cache_object.user_source = @cache_object.user_source
         
     | 
| 
      
 37 
     | 
    
         
            +
                  new_cache_object.category_id = @cache_object.category_id
         
     | 
| 
      
 38 
     | 
    
         
            +
                  new_cache_object.duration = @cache_object.duration
         
     | 
| 
      
 39 
     | 
    
         
            +
                  new_cache_object.play_path = @cache_object.play_path
         
     | 
| 
      
 40 
     | 
    
         
            +
                  new_cache_object.play_path_32 = @cache_object.play_path_32
         
     | 
| 
      
 41 
     | 
    
         
            +
                  new_cache_object.play_path_64 = @cache_object.play_path_64
         
     | 
| 
      
 42 
     | 
    
         
            +
                  new_cache_object.play_path_128 = @cache_object.play_path_128
         
     | 
| 
      
 43 
     | 
    
         
            +
                  new_cache_object.transcode_state = @cache_object.transcode_state
         
     | 
| 
      
 44 
     | 
    
         
            +
                  new_cache_object.download_path = @cache_object.download_path
         
     | 
| 
      
 45 
     | 
    
         
            +
                  new_cache_object.cover_path = @cache_object.cover_path
         
     | 
| 
      
 46 
     | 
    
         
            +
                  new_cache_object.album_id = @cache_object.album_id
         
     | 
| 
      
 47 
     | 
    
         
            +
                  new_cache_object.album_title = @cache_object.album_title
         
     | 
| 
      
 48 
     | 
    
         
            +
                  new_cache_object.album_cover_path = @cache_object.album_cover_path
         
     | 
| 
      
 49 
     | 
    
         
            +
                  new_cache_object.tags = @cache_object.tags
         
     | 
| 
      
 50 
     | 
    
         
            +
                  new_cache_object.ignore_tags = @cache_object.ignore_tags
         
     | 
| 
      
 51 
     | 
    
         
            +
                  new_cache_object.extra_tags = @cache_object.extra_tags
         
     | 
| 
      
 52 
     | 
    
         
            +
                  new_cache_object.singer = @cache_object.singer
         
     | 
| 
      
 53 
     | 
    
         
            +
                  new_cache_object.singer_category = @cache_object.singer_category
         
     | 
| 
      
 54 
     | 
    
         
            +
                  new_cache_object.author = @cache_object.author
         
     | 
| 
      
 55 
     | 
    
         
            +
                  new_cache_object.composer = @cache_object.composer
         
     | 
| 
      
 56 
     | 
    
         
            +
                  new_cache_object.arrangement = @cache_object.arrangement
         
     | 
| 
      
 57 
     | 
    
         
            +
                  new_cache_object.post_production = @cache_object.post_production
         
     | 
| 
      
 58 
     | 
    
         
            +
                  new_cache_object.lyric_path = @cache_object.lyric_path
         
     | 
| 
      
 59 
     | 
    
         
            +
                  new_cache_object.lyric = @cache_object.lyric
         
     | 
| 
      
 60 
     | 
    
         
            +
                  new_cache_object.language = @cache_object.language
         
     | 
| 
      
 61 
     | 
    
         
            +
                  new_cache_object.resinger = @cache_object.resinger
         
     | 
| 
      
 62 
     | 
    
         
            +
                  new_cache_object.announcer = @cache_object.announcer
         
     | 
| 
      
 63 
     | 
    
         
            +
                  new_cache_object.is_public = @cache_object.is_public
         
     | 
| 
      
 64 
     | 
    
         
            +
                  new_cache_object.access_password = @cache_object.access_password
         
     | 
| 
      
 65 
     | 
    
         
            +
                  new_cache_object.allow_download = @cache_object.allow_download
         
     | 
| 
      
 66 
     | 
    
         
            +
                  new_cache_object.allow_comment = @cache_object.allow_comment
         
     | 
| 
      
 67 
     | 
    
         
            +
                  new_cache_object.is_crawler = @cache_object.is_crawler
         
     | 
| 
      
 68 
     | 
    
         
            +
                  new_cache_object.inet_aton_ip = @cache_object.inet_aton_ip
         
     | 
| 
      
 69 
     | 
    
         
            +
                  new_cache_object.longitude = @cache_object.longitude
         
     | 
| 
      
 70 
     | 
    
         
            +
                  new_cache_object.latitude = @cache_object.latitude
         
     | 
| 
      
 71 
     | 
    
         
            +
                  new_cache_object.music_category = @cache_object.music_category
         
     | 
| 
      
 72 
     | 
    
         
            +
                  new_cache_object.order_num = @cache_object.order_num
         
     | 
| 
      
 73 
     | 
    
         
            +
                  new_cache_object.is_pick = @cache_object.is_pick
         
     | 
| 
      
 74 
     | 
    
         
            +
                  new_cache_object.rich_intro = @cache_object.rich_intro
         
     | 
| 
      
 75 
     | 
    
         
            +
                  new_cache_object.short_intro = @cache_object.short_intro
         
     | 
| 
      
 76 
     | 
    
         
            +
                  new_cache_object.comment_content = @cache_object.comment_content
         
     | 
| 
      
 77 
     | 
    
         
            +
                  new_cache_object.comment_id = @cache_object.comment_id
         
     | 
| 
      
 78 
     | 
    
         
            +
                  new_cache_object.dig_status = @cache_object.dig_status
         
     | 
| 
      
 79 
     | 
    
         
            +
                  new_cache_object.approved_at = @cache_object.approved_at
         
     | 
| 
      
 80 
     | 
    
         
            +
                  new_cache_object.is_deleted = @cache_object.is_deleted
         
     | 
| 
      
 81 
     | 
    
         
            +
                  new_cache_object.mp3size = @cache_object.mp3size
         
     | 
| 
      
 82 
     | 
    
         
            +
                  new_cache_object.mp3size_32 = @cache_object.mp3size_32
         
     | 
| 
      
 83 
     | 
    
         
            +
                  new_cache_object.mp3size_64 = @cache_object.mp3size_64
         
     | 
| 
      
 84 
     | 
    
         
            +
                  new_cache_object.waveform = @cache_object.waveform
         
     | 
| 
      
 85 
     | 
    
         
            +
                  new_cache_object.upload_id = @cache_object.upload_id
         
     | 
| 
      
 86 
     | 
    
         
            +
                  new_cache_object.updated_at = @cache_object.updated_at
         
     | 
| 
      
 87 
     | 
    
         
            +
                  new_cache_object.created_at = @cache_object.created_at
         
     | 
| 
      
 88 
     | 
    
         
            +
                  new_cache_object.source_url = @cache_object.source_url
         
     | 
| 
      
 89 
     | 
    
         
            +
                  new_cache_object.status = @cache_object.status
         
     | 
| 
      
 90 
     | 
    
         
            +
                  new_cache_object.explore_height = @cache_object.explore_height
         
     | 
| 
      
 91 
     | 
    
         
            +
                  new_cache_object.id = i
         
     | 
| 
      
 92 
     | 
    
         
            +
                  @cache_objects.push new_cache_object
         
     | 
| 
      
 93 
     | 
    
         
            +
                  @keys.push new_cache_object.id 
         
     | 
| 
      
 94 
     | 
    
         
            +
                end
         
     | 
| 
      
 95 
     | 
    
         
            +
                puts "setup"
         
     | 
| 
      
 96 
     | 
    
         
            +
              end
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
              def test_get_set
         
     | 
| 
      
 99 
     | 
    
         
            +
                @field_object_cache.evict(1)
         
     | 
| 
      
 100 
     | 
    
         
            +
                object = @field_object_cache.get(1)
         
     | 
| 
      
 101 
     | 
    
         
            +
                assert_equal(nil,object)
         
     | 
| 
      
 102 
     | 
    
         
            +
                assert_equal(["OK",true],@field_object_cache.put(@cache_object))
         
     | 
| 
      
 103 
     | 
    
         
            +
                object = @field_object_cache.get(1)
         
     | 
| 
      
 104 
     | 
    
         
            +
                # type assert
         
     | 
| 
      
 105 
     | 
    
         
            +
                assert_equal(Time.name,object.created_at.class.name)
         
     | 
| 
      
 106 
     | 
    
         
            +
                assert_equal(Time.name,object.updated_at.class.name)
         
     | 
| 
      
 107 
     | 
    
         
            +
                assert_equal(Time.name,object.approved_at.class.name)
         
     | 
| 
      
 108 
     | 
    
         
            +
                assert_equal(FalseClass.name,object.is_crawler.class.name)
         
     | 
| 
      
 109 
     | 
    
         
            +
                assert_equal(TrueClass.name,object.is_public.class.name)
         
     | 
| 
      
 110 
     | 
    
         
            +
                assert_equal(Fixnum.name,object.mp3size.class.name)
         
     | 
| 
      
 111 
     | 
    
         
            +
                assert_equal(BigDecimal.name,object.longitude.class.name)
         
     | 
| 
      
 112 
     | 
    
         
            +
                assert_equal(Bignum.name,object.track_id.class.name)
         
     | 
| 
      
 113 
     | 
    
         
            +
                assert_equal(String.name,object.play_path.class.name)
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
                #value assert
         
     | 
| 
      
 116 
     | 
    
         
            +
                assert_equal(@cache_object.track_id,object.track_id)
         
     | 
| 
      
 117 
     | 
    
         
            +
                assert_equal(@cache_object.track_uid,object.track_uid)
         
     | 
| 
      
 118 
     | 
    
         
            +
                assert_equal(@cache_object.track_upload_source,object.track_upload_source)
         
     | 
| 
      
 119 
     | 
    
         
            +
                assert_equal(@cache_object.op_type,object.op_type)
         
     | 
| 
      
 120 
     | 
    
         
            +
                assert_equal(@cache_object.is_public,object.is_public)
         
     | 
| 
      
 121 
     | 
    
         
            +
                assert_equal(@cache_object.upload_source,object.upload_source)
         
     | 
| 
      
 122 
     | 
    
         
            +
                assert_equal(@cache_object.uid,object.uid)
         
     | 
| 
      
 123 
     | 
    
         
            +
                assert_equal(@cache_object.nickname,object.nickname)
         
     | 
| 
      
 124 
     | 
    
         
            +
                assert_equal(@cache_object.title,object.title)
         
     | 
| 
      
 125 
     | 
    
         
            +
                assert_equal(@cache_object.intro,object.intro)
         
     | 
| 
      
 126 
     | 
    
         
            +
                assert_equal(@cache_object.play_path,object.play_path)
         
     | 
| 
      
 127 
     | 
    
         
            +
                assert_equal(@cache_object.is_crawler,object.is_crawler)
         
     | 
| 
      
 128 
     | 
    
         
            +
                assert_equal(@cache_object.approved_at,object.approved_at)
         
     | 
| 
      
 129 
     | 
    
         
            +
                assert_equal(@cache_object.mp3size,object.mp3size)
         
     | 
| 
      
 130 
     | 
    
         
            +
                assert_equal(@cache_object.updated_at,object.updated_at)
         
     | 
| 
      
 131 
     | 
    
         
            +
                assert_equal(@cache_object.created_at,object.created_at)
         
     | 
| 
      
 132 
     | 
    
         
            +
                assert_equal(@cache_object.id,object.id)
         
     | 
| 
      
 133 
     | 
    
         
            +
                assert_equal(@cache_object.longitude,object.longitude)
         
     | 
| 
      
 134 
     | 
    
         
            +
                assert_equal(@cache_object.duration,object.duration)
         
     | 
| 
      
 135 
     | 
    
         
            +
                # assert_equal(@cache_object.is_deleted,object.is_deleted)
         
     | 
| 
      
 136 
     | 
    
         
            +
                # assert_equal(@cache_object.is_publish,object.is_publish)
         
     | 
| 
      
 137 
     | 
    
         
            +
                # assert_equal(@cache_object.avatar_path,object.avatar_path)
         
     | 
| 
      
 138 
     | 
    
         
            +
                # assert_equal(@cache_object.is_v,object.is_v)
         
     | 
| 
      
 139 
     | 
    
         
            +
                # assert_equal(@cache_object.human_category_id,object.human_category_id)
         
     | 
| 
      
 140 
     | 
    
         
            +
                # assert_equal(@cache_object.user_source,object.user_source)
         
     | 
| 
      
 141 
     | 
    
         
            +
                # assert_equal(@cache_object.category_id,object.category_id)
         
     | 
| 
      
 142 
     | 
    
         
            +
                # assert_equal(@cache_object.play_path_32,object.play_path_32)
         
     | 
| 
      
 143 
     | 
    
         
            +
                # assert_equal(@cache_object.play_path_64,object.play_path_64)
         
     | 
| 
      
 144 
     | 
    
         
            +
                # assert_equal(@cache_object.play_path_128,object.play_path_128)
         
     | 
| 
      
 145 
     | 
    
         
            +
                # assert_equal(@cache_object.transcode_state,object.transcode_state)
         
     | 
| 
      
 146 
     | 
    
         
            +
                # assert_equal(@cache_object.download_path,object.download_path)
         
     | 
| 
      
 147 
     | 
    
         
            +
                # assert_equal(@cache_object.cover_path,object.cover_path)
         
     | 
| 
      
 148 
     | 
    
         
            +
                # assert_equal(@cache_object.album_id,object.album_id)
         
     | 
| 
      
 149 
     | 
    
         
            +
                # assert_equal(@cache_object.album_title,object.album_title)
         
     | 
| 
      
 150 
     | 
    
         
            +
                # assert_equal(@cache_object.album_cover_path,object.album_cover_path)
         
     | 
| 
      
 151 
     | 
    
         
            +
                # assert_equal(@cache_object.tags,object.tags)
         
     | 
| 
      
 152 
     | 
    
         
            +
                # assert_equal(@cache_object.ignore_tags,object.ignore_tags)
         
     | 
| 
      
 153 
     | 
    
         
            +
                # assert_equal(@cache_object.extra_tags,object.extra_tags)
         
     | 
| 
      
 154 
     | 
    
         
            +
                # assert_equal(@cache_object.singer,object.singer)
         
     | 
| 
      
 155 
     | 
    
         
            +
                # assert_equal(@cache_object.singer_category,object.singer_category)
         
     | 
| 
      
 156 
     | 
    
         
            +
                # assert_equal(@cache_object.author,object.author)
         
     | 
| 
      
 157 
     | 
    
         
            +
                # assert_equal(@cache_object.composer,object.composer)
         
     | 
| 
      
 158 
     | 
    
         
            +
                # assert_equal(@cache_object.arrangement,object.arrangement)
         
     | 
| 
      
 159 
     | 
    
         
            +
                # assert_equal(@cache_object.post_production,object.post_production)
         
     | 
| 
      
 160 
     | 
    
         
            +
                # assert_equal(@cache_object.lyric_path,object.lyric_path)
         
     | 
| 
      
 161 
     | 
    
         
            +
                # assert_equal(@cache_object.language,object.language)
         
     | 
| 
      
 162 
     | 
    
         
            +
                # assert_equal(@cache_object.lyric,object.lyric)
         
     | 
| 
      
 163 
     | 
    
         
            +
                # assert_equal(@cache_object.resinger,object.resinger)
         
     | 
| 
      
 164 
     | 
    
         
            +
                # assert_equal(@cache_object.announcer,object.announcer)
         
     | 
| 
      
 165 
     | 
    
         
            +
                # assert_equal(@cache_object.access_password,object.access_password)
         
     | 
| 
      
 166 
     | 
    
         
            +
                # assert_equal(@cache_object.allow_download,object.allow_download)
         
     | 
| 
      
 167 
     | 
    
         
            +
                # assert_equal(@cache_object.allow_comment,object.allow_comment)
         
     | 
| 
      
 168 
     | 
    
         
            +
                # assert_equal(@cache_object.inet_aton_ip,object.inet_aton_ip)
         
     | 
| 
      
 169 
     | 
    
         
            +
                # assert_equal(@cache_object.latitude,object.latitude)
         
     | 
| 
      
 170 
     | 
    
         
            +
                # assert_equal(@cache_object.music_category,object.music_category)
         
     | 
| 
      
 171 
     | 
    
         
            +
                # assert_equal(@cache_object.order_num,object.order_num)
         
     | 
| 
      
 172 
     | 
    
         
            +
                # assert_equal(@cache_object.is_pick,object.is_pick)
         
     | 
| 
      
 173 
     | 
    
         
            +
                # assert_equal(@cache_object.rich_intro,object.rich_intro)
         
     | 
| 
      
 174 
     | 
    
         
            +
                # assert_equal(@cache_object.short_intro,object.short_intro)
         
     | 
| 
      
 175 
     | 
    
         
            +
                # assert_equal(@cache_object.comment_content,object.comment_content)
         
     | 
| 
      
 176 
     | 
    
         
            +
                # assert_equal(@cache_object.comment_id,object.comment_id)
         
     | 
| 
      
 177 
     | 
    
         
            +
                # assert_equal(@cache_object.dig_status,object.dig_status)
         
     | 
| 
      
 178 
     | 
    
         
            +
                # assert_equal(@cache_object.mp3size_32,object.mp3size_32)
         
     | 
| 
      
 179 
     | 
    
         
            +
                # assert_equal(@cache_object.mp3size_64,object.mp3size_64)
         
     | 
| 
      
 180 
     | 
    
         
            +
                # assert_equal(@cache_object.waveform,object.waveform)
         
     | 
| 
      
 181 
     | 
    
         
            +
                # assert_equal(@cache_object.upload_id,object.upload_id)
         
     | 
| 
      
 182 
     | 
    
         
            +
                # assert_equal(@cache_object.source_url,object.source_url)
         
     | 
| 
      
 183 
     | 
    
         
            +
                # assert_equal(@cache_object.status,object.status)
         
     | 
| 
      
 184 
     | 
    
         
            +
                # assert_equal(@cache_object.explore_height,object.explore_height)
         
     | 
| 
      
 185 
     | 
    
         
            +
              end
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
              def test_get_set_benchmark
         
     | 
| 
      
 188 
     | 
    
         
            +
                @field_object_cache.evict(1)
         
     | 
| 
      
 189 
     | 
    
         
            +
                times = 1000
         
     | 
| 
      
 190 
     | 
    
         
            +
                start = Time.now
         
     | 
| 
      
 191 
     | 
    
         
            +
                for i in 1 .. times do
         
     | 
| 
      
 192 
     | 
    
         
            +
                  @field_object_cache.put(@cache_object)
         
     | 
| 
      
 193 
     | 
    
         
            +
                end
         
     | 
| 
      
 194 
     | 
    
         
            +
                stop = Time.now
         
     | 
| 
      
 195 
     | 
    
         
            +
                puts "#{times} times put operation total use #{stop-start} seconds"
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
                start = Time.now
         
     | 
| 
      
 198 
     | 
    
         
            +
                for i in 1 .. times do
         
     | 
| 
      
 199 
     | 
    
         
            +
                  @field_object_cache.get(1)
         
     | 
| 
      
 200 
     | 
    
         
            +
                end
         
     | 
| 
      
 201 
     | 
    
         
            +
                stop = Time.now
         
     | 
| 
      
 202 
     | 
    
         
            +
                puts "#{times} times get operation total use #{stop-start} seconds"
         
     | 
| 
      
 203 
     | 
    
         
            +
              end
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
              def test_mget_mset
         
     | 
| 
      
 206 
     | 
    
         
            +
                @field_object_cache.batch_evict @keys
         
     | 
| 
      
 207 
     | 
    
         
            +
                result = @field_object_cache.multi_put(@cache_objects)
         
     | 
| 
      
 208 
     | 
    
         
            +
                for i in 0 .. result.length / 2 - 1 do
         
     | 
| 
      
 209 
     | 
    
         
            +
                  k = i * 2
         
     | 
| 
      
 210 
     | 
    
         
            +
                  assert_equal("OK",result[k])
         
     | 
| 
      
 211 
     | 
    
         
            +
                  assert_equal(true,result[k+1])
         
     | 
| 
      
 212 
     | 
    
         
            +
                end
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
                objects = @field_object_cache.multi_get(@keys)
         
     | 
| 
      
 215 
     | 
    
         
            +
                assert_equal(@cache_objects.length, objects.length)
         
     | 
| 
      
 216 
     | 
    
         
            +
                for i in 0 .. @cache_objects.length - 1 do
         
     | 
| 
      
 217 
     | 
    
         
            +
                  assert_equal(Time.name,objects[i].created_at.class.name)
         
     | 
| 
      
 218 
     | 
    
         
            +
                  assert_equal(Time.name,objects[i].updated_at.class.name)
         
     | 
| 
      
 219 
     | 
    
         
            +
                  assert_equal(Time.name,objects[i].approved_at.class.name)
         
     | 
| 
      
 220 
     | 
    
         
            +
                  assert_equal(FalseClass.name,objects[i].is_crawler.class.name)
         
     | 
| 
      
 221 
     | 
    
         
            +
                  assert_equal(TrueClass.name,objects[i].is_public.class.name)
         
     | 
| 
      
 222 
     | 
    
         
            +
                  assert_equal(Fixnum.name,objects[i].mp3size.class.name)
         
     | 
| 
      
 223 
     | 
    
         
            +
                  assert_equal(BigDecimal.name,objects[i].longitude.class.name)
         
     | 
| 
      
 224 
     | 
    
         
            +
                  assert_equal(Bignum.name,objects[i].track_id.class.name)
         
     | 
| 
      
 225 
     | 
    
         
            +
                  assert_equal(String.name,objects[i].play_path.class.name)
         
     | 
| 
      
 226 
     | 
    
         
            +
             
     | 
| 
      
 227 
     | 
    
         
            +
                  #VALUE assert
         
     | 
| 
      
 228 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].track_id,objects[i].track_id)
         
     | 
| 
      
 229 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].track_uid,objects[i].track_uid)
         
     | 
| 
      
 230 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].track_upload_source,objects[i].track_upload_source)
         
     | 
| 
      
 231 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].op_type,objects[i].op_type)
         
     | 
| 
      
 232 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].is_publish,objects[i].is_publish)
         
     | 
| 
      
 233 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].upload_source,objects[i].upload_source)
         
     | 
| 
      
 234 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].uid,objects[i].uid)
         
     | 
| 
      
 235 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].nickname,objects[i].nickname)
         
     | 
| 
      
 236 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].title,objects[i].title)
         
     | 
| 
      
 237 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].intro,objects[i].intro)
         
     | 
| 
      
 238 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].duration,objects[i].duration)
         
     | 
| 
      
 239 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].play_path,objects[i].play_path)
         
     | 
| 
      
 240 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].is_public,objects[i].is_public)
         
     | 
| 
      
 241 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].is_crawler,objects[i].is_crawler)
         
     | 
| 
      
 242 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].longitude,objects[i].longitude)
         
     | 
| 
      
 243 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].approved_at,objects[i].approved_at)
         
     | 
| 
      
 244 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].mp3size,objects[i].mp3size)
         
     | 
| 
      
 245 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].updated_at,objects[i].updated_at)
         
     | 
| 
      
 246 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].created_at,objects[i].created_at)
         
     | 
| 
      
 247 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].id,objects[i].id)
         
     | 
| 
      
 248 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].avatar_path,objects[i].avatar_path)
         
     | 
| 
      
 249 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].is_v,objects[i].is_v)
         
     | 
| 
      
 250 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].human_category_id,objects[i].human_category_id)
         
     | 
| 
      
 251 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].user_source,objects[i].user_source)
         
     | 
| 
      
 252 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].category_id,objects[i].category_id)
         
     | 
| 
      
 253 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].play_path_32,objects[i].play_path_32)
         
     | 
| 
      
 254 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].play_path_64,objects[i].play_path_64)
         
     | 
| 
      
 255 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].play_path_128,objects[i].play_path_128)
         
     | 
| 
      
 256 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].transcode_state,objects[i].transcode_state)
         
     | 
| 
      
 257 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].download_path,objects[i].download_path)
         
     | 
| 
      
 258 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].cover_path,objects[i].cover_path)
         
     | 
| 
      
 259 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].album_id,objects[i].album_id)
         
     | 
| 
      
 260 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].album_title,objects[i].album_title)
         
     | 
| 
      
 261 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].album_cover_path,objects[i].album_cover_path)
         
     | 
| 
      
 262 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].tags,objects[i].tags)
         
     | 
| 
      
 263 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].ignore_tags,objects[i].ignore_tags)
         
     | 
| 
      
 264 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].extra_tags,objects[i].extra_tags)
         
     | 
| 
      
 265 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].singer,objects[i].singer)
         
     | 
| 
      
 266 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].singer_category,objects[i].singer_category)
         
     | 
| 
      
 267 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].author,objects[i].author)
         
     | 
| 
      
 268 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].composer,objects[i].composer)
         
     | 
| 
      
 269 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].arrangement,objects[i].arrangement)
         
     | 
| 
      
 270 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].post_production,objects[i].post_production)
         
     | 
| 
      
 271 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].lyric_path,objects[i].lyric_path)
         
     | 
| 
      
 272 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].language,objects[i].language)
         
     | 
| 
      
 273 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].lyric,objects[i].lyric)
         
     | 
| 
      
 274 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].resinger,objects[i].resinger)
         
     | 
| 
      
 275 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].announcer,objects[i].announcer)
         
     | 
| 
      
 276 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].access_password,objects[i].access_password)
         
     | 
| 
      
 277 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].allow_download,objects[i].allow_download)
         
     | 
| 
      
 278 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].allow_comment,objects[i].allow_comment)
         
     | 
| 
      
 279 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].inet_aton_ip,objects[i].inet_aton_ip)
         
     | 
| 
      
 280 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].latitude,objects[i].latitude)
         
     | 
| 
      
 281 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].music_category,objects[i].music_category)
         
     | 
| 
      
 282 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].order_num,objects[i].order_num)
         
     | 
| 
      
 283 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].is_pick,objects[i].is_pick)
         
     | 
| 
      
 284 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].rich_intro,objects[i].rich_intro)
         
     | 
| 
      
 285 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].short_intro,objects[i].short_intro)
         
     | 
| 
      
 286 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].comment_content,objects[i].comment_content)
         
     | 
| 
      
 287 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].comment_id,objects[i].comment_id)
         
     | 
| 
      
 288 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].dig_status,objects[i].dig_status)
         
     | 
| 
      
 289 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].is_deleted,objects[i].is_deleted)
         
     | 
| 
      
 290 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].mp3size_32,objects[i].mp3size_32)
         
     | 
| 
      
 291 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].mp3size_64,objects[i].mp3size_64)
         
     | 
| 
      
 292 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].waveform,objects[i].waveform)
         
     | 
| 
      
 293 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].upload_id,objects[i].upload_id)
         
     | 
| 
      
 294 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].source_url,objects[i].source_url)
         
     | 
| 
      
 295 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].status,objects[i].status)
         
     | 
| 
      
 296 
     | 
    
         
            +
                  # assert_equal(@cache_objects[i].explore_height,objects[i].explore_height)
         
     | 
| 
      
 297 
     | 
    
         
            +
                end
         
     | 
| 
      
 298 
     | 
    
         
            +
              end
         
     | 
| 
      
 299 
     | 
    
         
            +
             
     | 
| 
      
 300 
     | 
    
         
            +
              def test_mget_mset_benchmark
         
     | 
| 
      
 301 
     | 
    
         
            +
                @field_object_cache.batch_evict @keys
         
     | 
| 
      
 302 
     | 
    
         
            +
             
     | 
| 
      
 303 
     | 
    
         
            +
                times = 1000
         
     | 
| 
      
 304 
     | 
    
         
            +
                start = Time.now
         
     | 
| 
      
 305 
     | 
    
         
            +
                for i in 1 .. times do
         
     | 
| 
      
 306 
     | 
    
         
            +
                  @field_object_cache.multi_put(@cache_objects)
         
     | 
| 
      
 307 
     | 
    
         
            +
                end
         
     | 
| 
      
 308 
     | 
    
         
            +
                stop = Time.now
         
     | 
| 
      
 309 
     | 
    
         
            +
                puts "#{times} times multi_put operation total use #{stop-start} seconds"
         
     | 
| 
      
 310 
     | 
    
         
            +
             
     | 
| 
      
 311 
     | 
    
         
            +
                start = Time.now
         
     | 
| 
      
 312 
     | 
    
         
            +
                for i in 1 .. times do
         
     | 
| 
      
 313 
     | 
    
         
            +
                  @field_object_cache.multi_get(@keys)
         
     | 
| 
      
 314 
     | 
    
         
            +
                end
         
     | 
| 
      
 315 
     | 
    
         
            +
                stop = Time.now
         
     | 
| 
      
 316 
     | 
    
         
            +
                puts "#{times} times multi_get operation total use #{stop-start} seconds"
         
     | 
| 
      
 317 
     | 
    
         
            +
              end
         
     | 
| 
      
 318 
     | 
    
         
            +
             
     | 
| 
      
 319 
     | 
    
         
            +
              def test_evict
         
     | 
| 
      
 320 
     | 
    
         
            +
                @field_object_cache.batch_evict(@keys)
         
     | 
| 
      
 321 
     | 
    
         
            +
              end
         
     | 
| 
      
 322 
     | 
    
         
            +
             
     | 
| 
      
 323 
     | 
    
         
            +
              def test_get_set_with_field
         
     | 
| 
      
 324 
     | 
    
         
            +
                # you must convert fields first
         
     | 
| 
      
 325 
     | 
    
         
            +
                
         
     | 
| 
      
 326 
     | 
    
         
            +
                @field_object_cache.evict(1)
         
     | 
| 
      
 327 
     | 
    
         
            +
                object = @field_object_cache.get_with_field(1,@fields)
         
     | 
| 
      
 328 
     | 
    
         
            +
                assert_equal(nil,object)
         
     | 
| 
      
 329 
     | 
    
         
            +
                assert_equal(["OK",true],@field_object_cache.put_with_field(@cache_object,@fields))
         
     | 
| 
      
 330 
     | 
    
         
            +
                object = @field_object_cache.get_with_field(1,@fields)
         
     | 
| 
      
 331 
     | 
    
         
            +
                assert_equal(Time.name,object.created_at.class.name)
         
     | 
| 
      
 332 
     | 
    
         
            +
                assert_equal(Time.name,object.updated_at.class.name)
         
     | 
| 
      
 333 
     | 
    
         
            +
                assert_equal(Time.name,object.approved_at.class.name)
         
     | 
| 
      
 334 
     | 
    
         
            +
                assert_equal(FalseClass.name,object.is_crawler.class.name)
         
     | 
| 
      
 335 
     | 
    
         
            +
                assert_equal(TrueClass.name,object.is_public.class.name)
         
     | 
| 
      
 336 
     | 
    
         
            +
                assert_equal(Fixnum.name,object.mp3size.class.name)
         
     | 
| 
      
 337 
     | 
    
         
            +
                assert_equal(BigDecimal.name,object.longitude.class.name)
         
     | 
| 
      
 338 
     | 
    
         
            +
                assert_equal(Bignum.name,object.track_id.class.name)
         
     | 
| 
      
 339 
     | 
    
         
            +
                assert_equal(String.name,object.play_path.class.name)
         
     | 
| 
      
 340 
     | 
    
         
            +
             
     | 
| 
      
 341 
     | 
    
         
            +
                #value assert
         
     | 
| 
      
 342 
     | 
    
         
            +
                assert_equal(@cache_object.track_id,object.track_id)
         
     | 
| 
      
 343 
     | 
    
         
            +
                assert_equal(@cache_object.play_path,object.play_path)
         
     | 
| 
      
 344 
     | 
    
         
            +
                assert_equal(@cache_object.is_public,object.is_public)
         
     | 
| 
      
 345 
     | 
    
         
            +
                assert_equal(@cache_object.is_crawler,object.is_crawler)
         
     | 
| 
      
 346 
     | 
    
         
            +
                assert_equal(@cache_object.longitude,object.longitude)
         
     | 
| 
      
 347 
     | 
    
         
            +
                assert_equal(@cache_object.approved_at,object.approved_at)
         
     | 
| 
      
 348 
     | 
    
         
            +
                assert_equal(@cache_object.mp3size,object.mp3size)
         
     | 
| 
      
 349 
     | 
    
         
            +
                assert_equal(@cache_object.updated_at,object.updated_at)
         
     | 
| 
      
 350 
     | 
    
         
            +
                assert_equal(@cache_object.created_at,object.created_at)
         
     | 
| 
      
 351 
     | 
    
         
            +
              end
         
     | 
| 
      
 352 
     | 
    
         
            +
             
     | 
| 
      
 353 
     | 
    
         
            +
              def test_get_set_with_field_benchmark
         
     | 
| 
      
 354 
     | 
    
         
            +
                @field_object_cache.evict(1)
         
     | 
| 
      
 355 
     | 
    
         
            +
                times = 1000
         
     | 
| 
      
 356 
     | 
    
         
            +
                start = Time.now
         
     | 
| 
      
 357 
     | 
    
         
            +
                for i in 1 .. times do
         
     | 
| 
      
 358 
     | 
    
         
            +
                  @field_object_cache.put_with_field(@cache_object,@fields)
         
     | 
| 
      
 359 
     | 
    
         
            +
                end
         
     | 
| 
      
 360 
     | 
    
         
            +
                stop = Time.now
         
     | 
| 
      
 361 
     | 
    
         
            +
                puts "#{times} times put_with_field operation total use #{stop-start} seconds"
         
     | 
| 
      
 362 
     | 
    
         
            +
             
     | 
| 
      
 363 
     | 
    
         
            +
                start = Time.now
         
     | 
| 
      
 364 
     | 
    
         
            +
                for i in 1 .. times do
         
     | 
| 
      
 365 
     | 
    
         
            +
                  @field_object_cache.get_with_field(1,@fields)
         
     | 
| 
      
 366 
     | 
    
         
            +
                end
         
     | 
| 
      
 367 
     | 
    
         
            +
                stop = Time.now
         
     | 
| 
      
 368 
     | 
    
         
            +
                puts "#{times} times get_with_field operation total use #{stop-start} seconds"
         
     | 
| 
      
 369 
     | 
    
         
            +
              end
         
     | 
| 
      
 370 
     | 
    
         
            +
             
     | 
| 
      
 371 
     | 
    
         
            +
              def test_mget_mset_with_field
         
     | 
| 
      
 372 
     | 
    
         
            +
                @field_object_cache.batch_evict @keys
         
     | 
| 
      
 373 
     | 
    
         
            +
                result = @field_object_cache.multi_put_with_field(@cache_objects,@fields)
         
     | 
| 
      
 374 
     | 
    
         
            +
                for i in 0 .. result.length / 2 - 1 do
         
     | 
| 
      
 375 
     | 
    
         
            +
                  k = i * 2
         
     | 
| 
      
 376 
     | 
    
         
            +
                  assert_equal("OK",result[k])
         
     | 
| 
      
 377 
     | 
    
         
            +
                  assert_equal(true,result[k+1])
         
     | 
| 
      
 378 
     | 
    
         
            +
                end
         
     | 
| 
      
 379 
     | 
    
         
            +
             
     | 
| 
      
 380 
     | 
    
         
            +
                objects = @field_object_cache.multi_get_with_field(@keys,@fields)
         
     | 
| 
      
 381 
     | 
    
         
            +
                assert_equal(@cache_objects.length, objects.length)
         
     | 
| 
      
 382 
     | 
    
         
            +
                for i in 0 .. @cache_objects.length - 1 do
         
     | 
| 
      
 383 
     | 
    
         
            +
                  assert_equal(Time.name,objects[i].created_at.class.name)
         
     | 
| 
      
 384 
     | 
    
         
            +
                  assert_equal(Time.name,objects[i].updated_at.class.name)
         
     | 
| 
      
 385 
     | 
    
         
            +
                  assert_equal(Time.name,objects[i].approved_at.class.name)
         
     | 
| 
      
 386 
     | 
    
         
            +
                  assert_equal(FalseClass.name,objects[i].is_crawler.class.name)
         
     | 
| 
      
 387 
     | 
    
         
            +
                  assert_equal(TrueClass.name,objects[i].is_public.class.name)
         
     | 
| 
      
 388 
     | 
    
         
            +
                  assert_equal(Fixnum.name,objects[i].mp3size.class.name)
         
     | 
| 
      
 389 
     | 
    
         
            +
                  assert_equal(BigDecimal.name,objects[i].longitude.class.name)
         
     | 
| 
      
 390 
     | 
    
         
            +
                  assert_equal(Bignum.name,objects[i].track_id.class.name)
         
     | 
| 
      
 391 
     | 
    
         
            +
                  assert_equal(String.name,objects[i].play_path.class.name)
         
     | 
| 
      
 392 
     | 
    
         
            +
             
     | 
| 
      
 393 
     | 
    
         
            +
                  #VALUE assert
         
     | 
| 
      
 394 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].track_id,objects[i].track_id)
         
     | 
| 
      
 395 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].play_path,objects[i].play_path)
         
     | 
| 
      
 396 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].is_public,objects[i].is_public)
         
     | 
| 
      
 397 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].is_crawler,objects[i].is_crawler)
         
     | 
| 
      
 398 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].longitude,objects[i].longitude)
         
     | 
| 
      
 399 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].approved_at,objects[i].approved_at)
         
     | 
| 
      
 400 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].mp3size,objects[i].mp3size)
         
     | 
| 
      
 401 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].updated_at,objects[i].updated_at)
         
     | 
| 
      
 402 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].created_at,objects[i].created_at)
         
     | 
| 
      
 403 
     | 
    
         
            +
                end
         
     | 
| 
      
 404 
     | 
    
         
            +
              end
         
     | 
| 
      
 405 
     | 
    
         
            +
             
     | 
| 
      
 406 
     | 
    
         
            +
              def test_mget_mset_with_field_benchmark
         
     | 
| 
      
 407 
     | 
    
         
            +
                @field_object_cache.batch_evict @keys
         
     | 
| 
      
 408 
     | 
    
         
            +
                times = 1000
         
     | 
| 
      
 409 
     | 
    
         
            +
                start = Time.now
         
     | 
| 
      
 410 
     | 
    
         
            +
                for i in 1 .. times do
         
     | 
| 
      
 411 
     | 
    
         
            +
                  @field_object_cache.multi_put_with_field(@cache_objects,@fields)
         
     | 
| 
      
 412 
     | 
    
         
            +
                end
         
     | 
| 
      
 413 
     | 
    
         
            +
                stop = Time.now
         
     | 
| 
      
 414 
     | 
    
         
            +
                puts "#{times} times multi_put_with_field operation total use #{stop-start} seconds"
         
     | 
| 
      
 415 
     | 
    
         
            +
             
     | 
| 
      
 416 
     | 
    
         
            +
                start = Time.now
         
     | 
| 
      
 417 
     | 
    
         
            +
                for i in 1 .. times do
         
     | 
| 
      
 418 
     | 
    
         
            +
                  @field_object_cache.multi_get_with_field(@keys,@fields)
         
     | 
| 
      
 419 
     | 
    
         
            +
                end
         
     | 
| 
      
 420 
     | 
    
         
            +
                stop = Time.now
         
     | 
| 
      
 421 
     | 
    
         
            +
                puts "#{times} times multi_get_with_field operation total use #{stop-start} seconds"
         
     | 
| 
      
 422 
     | 
    
         
            +
              end
         
     | 
| 
      
 423 
     | 
    
         
            +
             
     | 
| 
      
 424 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 425 
     | 
    
         
            +
                super
         
     | 
| 
      
 426 
     | 
    
         
            +
                @field_object_cache.destroy
         
     | 
| 
      
 427 
     | 
    
         
            +
                puts "teardown"
         
     | 
| 
      
 428 
     | 
    
         
            +
              end
         
     | 
| 
      
 429 
     | 
    
         
            +
            end
         
     | 
| 
      
 430 
     | 
    
         
            +
             
     |