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,45 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $:.unshift File.expand_path("../../lib", __FILE__)
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "test/unit"
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'xunch'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            class NginxCacheHelperTest < Test::Unit::TestCase
         
     | 
| 
      
 6 
     | 
    
         
            +
              include Test::Unit::Assertions
         
     | 
| 
      
 7 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 8 
     | 
    
         
            +
                super
         
     | 
| 
      
 9 
     | 
    
         
            +
                @helper = Xunch::NginxCacheHelper.new("www.ximalaya.com",nil,10)
         
     | 
| 
      
 10 
     | 
    
         
            +
                puts "setup"
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              def test_evict
         
     | 
| 
      
 14 
     | 
    
         
            +
                assert_true(@helper.evict("/1000001/"))
         
     | 
| 
      
 15 
     | 
    
         
            +
                assert_true(@helper.evict("/1000002/"))
         
     | 
| 
      
 16 
     | 
    
         
            +
                assert_true(@helper.evict("/1000003/"))
         
     | 
| 
      
 17 
     | 
    
         
            +
                assert_true(@helper.evict("/1000004/"))
         
     | 
| 
      
 18 
     | 
    
         
            +
                assert_true(@helper.evict("/1000005/"))
         
     | 
| 
      
 19 
     | 
    
         
            +
                assert_true(@helper.evict("/1000006/"))
         
     | 
| 
      
 20 
     | 
    
         
            +
                assert_true(@helper.evict("/1000007/"))
         
     | 
| 
      
 21 
     | 
    
         
            +
                assert_true(@helper.evict("/1000008/"))
         
     | 
| 
      
 22 
     | 
    
         
            +
                assert_true(@helper.evict("/1000009/"))
         
     | 
| 
      
 23 
     | 
    
         
            +
                assert_true(@helper.evict("/1000010/"))
         
     | 
| 
      
 24 
     | 
    
         
            +
                assert_false(@helper.cache("/1000010"))
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              def test_cache
         
     | 
| 
      
 28 
     | 
    
         
            +
                assert_true(@helper.cache("/1000001/"))
         
     | 
| 
      
 29 
     | 
    
         
            +
                assert_true(@helper.cache("/1000002/"))
         
     | 
| 
      
 30 
     | 
    
         
            +
                assert_true(@helper.cache("/1000003/"))
         
     | 
| 
      
 31 
     | 
    
         
            +
                assert_true(@helper.cache("/1000004/"))
         
     | 
| 
      
 32 
     | 
    
         
            +
                assert_true(@helper.cache("/1000005/"))
         
     | 
| 
      
 33 
     | 
    
         
            +
                assert_true(@helper.cache("/1000006/"))
         
     | 
| 
      
 34 
     | 
    
         
            +
                assert_true(@helper.cache("/1000007/"))
         
     | 
| 
      
 35 
     | 
    
         
            +
                assert_true(@helper.cache("/1000008/"))
         
     | 
| 
      
 36 
     | 
    
         
            +
                assert_true(@helper.cache("/1000009/"))
         
     | 
| 
      
 37 
     | 
    
         
            +
                assert_true(@helper.cache("/1000010/"))
         
     | 
| 
      
 38 
     | 
    
         
            +
                assert_false(@helper.cache("/1000010"))
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 42 
     | 
    
         
            +
                super
         
     | 
| 
      
 43 
     | 
    
         
            +
                puts "teardown"
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,322 @@ 
     | 
|
| 
      
 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 'bigdecimal'
         
     | 
| 
      
 7 
     | 
    
         
            +
            require 'hessian2'
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'track_record_origin'
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            class ObjectCacheTest < Test::Unit::TestCase
         
     | 
| 
      
 11 
     | 
    
         
            +
              include Test::Unit::Assertions
         
     | 
| 
      
 12 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 13 
     | 
    
         
            +
                super
         
     | 
| 
      
 14 
     | 
    
         
            +
                root = File.expand_path("../..", __FILE__)
         
     | 
| 
      
 15 
     | 
    
         
            +
                file = File.join(root, 'test/xunch.yaml')
         
     | 
| 
      
 16 
     | 
    
         
            +
                caches = Xunch::CacheBuilder.build(file)
         
     | 
| 
      
 17 
     | 
    
         
            +
                @object_cache = caches["track"]
         
     | 
| 
      
 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 
     | 
    
         
            +
                assert_equal('OK',@object_cache.put(@cache_object))
         
     | 
| 
      
 100 
     | 
    
         
            +
                object = @object_cache.get(1)
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
                # type assert
         
     | 
| 
      
 103 
     | 
    
         
            +
                assert_equal(Time.name,object.created_at.class.name)
         
     | 
| 
      
 104 
     | 
    
         
            +
                assert_equal(Time.name,object.updated_at.class.name)
         
     | 
| 
      
 105 
     | 
    
         
            +
                assert_equal(Time.name,object.approved_at.class.name)
         
     | 
| 
      
 106 
     | 
    
         
            +
                assert_equal(FalseClass.name,object.is_crawler.class.name)
         
     | 
| 
      
 107 
     | 
    
         
            +
                assert_equal(TrueClass.name,object.is_public.class.name)
         
     | 
| 
      
 108 
     | 
    
         
            +
                assert_equal(Fixnum.name,object.mp3size.class.name)
         
     | 
| 
      
 109 
     | 
    
         
            +
                assert_equal(BigDecimal.name,object.longitude.class.name)
         
     | 
| 
      
 110 
     | 
    
         
            +
                assert_equal(Bignum.name,object.track_id.class.name)
         
     | 
| 
      
 111 
     | 
    
         
            +
                assert_equal(String.name,object.play_path.class.name)
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                #value assert
         
     | 
| 
      
 114 
     | 
    
         
            +
                assert_equal(@cache_object.track_id,object.track_id)
         
     | 
| 
      
 115 
     | 
    
         
            +
                assert_equal(@cache_object.track_uid,object.track_uid)
         
     | 
| 
      
 116 
     | 
    
         
            +
                assert_equal(@cache_object.track_upload_source,object.track_upload_source)
         
     | 
| 
      
 117 
     | 
    
         
            +
                assert_equal(@cache_object.op_type,object.op_type)
         
     | 
| 
      
 118 
     | 
    
         
            +
                assert_equal(@cache_object.is_publish,object.is_publish)
         
     | 
| 
      
 119 
     | 
    
         
            +
                assert_equal(@cache_object.upload_source,object.upload_source)
         
     | 
| 
      
 120 
     | 
    
         
            +
                assert_equal(@cache_object.uid,object.uid)
         
     | 
| 
      
 121 
     | 
    
         
            +
                assert_equal(@cache_object.nickname,object.nickname)
         
     | 
| 
      
 122 
     | 
    
         
            +
                assert_equal(@cache_object.avatar_path,object.avatar_path)
         
     | 
| 
      
 123 
     | 
    
         
            +
                assert_equal(@cache_object.is_v,object.is_v)
         
     | 
| 
      
 124 
     | 
    
         
            +
                assert_equal(@cache_object.human_category_id,object.human_category_id)
         
     | 
| 
      
 125 
     | 
    
         
            +
                assert_equal(@cache_object.title,object.title)
         
     | 
| 
      
 126 
     | 
    
         
            +
                assert_equal(@cache_object.intro,object.intro)
         
     | 
| 
      
 127 
     | 
    
         
            +
                assert_equal(@cache_object.user_source,object.user_source)
         
     | 
| 
      
 128 
     | 
    
         
            +
                assert_equal(@cache_object.category_id,object.category_id)
         
     | 
| 
      
 129 
     | 
    
         
            +
                assert_equal(@cache_object.duration,object.duration)
         
     | 
| 
      
 130 
     | 
    
         
            +
                assert_equal(@cache_object.play_path,object.play_path)
         
     | 
| 
      
 131 
     | 
    
         
            +
                assert_equal(@cache_object.play_path_32,object.play_path_32)
         
     | 
| 
      
 132 
     | 
    
         
            +
                assert_equal(@cache_object.play_path_64,object.play_path_64)
         
     | 
| 
      
 133 
     | 
    
         
            +
                assert_equal(@cache_object.play_path_128,object.play_path_128)
         
     | 
| 
      
 134 
     | 
    
         
            +
                assert_equal(@cache_object.transcode_state,object.transcode_state)
         
     | 
| 
      
 135 
     | 
    
         
            +
                assert_equal(@cache_object.download_path,object.download_path)
         
     | 
| 
      
 136 
     | 
    
         
            +
                assert_equal(@cache_object.cover_path,object.cover_path)
         
     | 
| 
      
 137 
     | 
    
         
            +
                assert_equal(@cache_object.album_id,object.album_id)
         
     | 
| 
      
 138 
     | 
    
         
            +
                assert_equal(@cache_object.album_title,object.album_title)
         
     | 
| 
      
 139 
     | 
    
         
            +
                assert_equal(@cache_object.album_cover_path,object.album_cover_path)
         
     | 
| 
      
 140 
     | 
    
         
            +
                assert_equal(@cache_object.tags,object.tags)
         
     | 
| 
      
 141 
     | 
    
         
            +
                assert_equal(@cache_object.ignore_tags,object.ignore_tags)
         
     | 
| 
      
 142 
     | 
    
         
            +
                assert_equal(@cache_object.extra_tags,object.extra_tags)
         
     | 
| 
      
 143 
     | 
    
         
            +
                assert_equal(@cache_object.singer,object.singer)
         
     | 
| 
      
 144 
     | 
    
         
            +
                assert_equal(@cache_object.singer_category,object.singer_category)
         
     | 
| 
      
 145 
     | 
    
         
            +
                assert_equal(@cache_object.author,object.author)
         
     | 
| 
      
 146 
     | 
    
         
            +
                assert_equal(@cache_object.composer,object.composer)
         
     | 
| 
      
 147 
     | 
    
         
            +
                assert_equal(@cache_object.arrangement,object.arrangement)
         
     | 
| 
      
 148 
     | 
    
         
            +
                assert_equal(@cache_object.post_production,object.post_production)
         
     | 
| 
      
 149 
     | 
    
         
            +
                assert_equal(@cache_object.lyric_path,object.lyric_path)
         
     | 
| 
      
 150 
     | 
    
         
            +
                assert_equal(@cache_object.language,object.language)
         
     | 
| 
      
 151 
     | 
    
         
            +
                assert_equal(@cache_object.lyric,object.lyric)
         
     | 
| 
      
 152 
     | 
    
         
            +
                assert_equal(@cache_object.resinger,object.resinger)
         
     | 
| 
      
 153 
     | 
    
         
            +
                assert_equal(@cache_object.announcer,object.announcer)
         
     | 
| 
      
 154 
     | 
    
         
            +
                assert_equal(@cache_object.is_public,object.is_public)
         
     | 
| 
      
 155 
     | 
    
         
            +
                assert_equal(@cache_object.access_password,object.access_password)
         
     | 
| 
      
 156 
     | 
    
         
            +
                assert_equal(@cache_object.allow_download,object.allow_download)
         
     | 
| 
      
 157 
     | 
    
         
            +
                assert_equal(@cache_object.allow_comment,object.allow_comment)
         
     | 
| 
      
 158 
     | 
    
         
            +
                assert_equal(@cache_object.is_crawler,object.is_crawler)
         
     | 
| 
      
 159 
     | 
    
         
            +
                assert_equal(@cache_object.inet_aton_ip,object.inet_aton_ip)
         
     | 
| 
      
 160 
     | 
    
         
            +
                assert_equal(@cache_object.longitude,object.longitude)
         
     | 
| 
      
 161 
     | 
    
         
            +
                assert_equal(@cache_object.latitude,object.latitude)
         
     | 
| 
      
 162 
     | 
    
         
            +
                assert_equal(@cache_object.music_category,object.music_category)
         
     | 
| 
      
 163 
     | 
    
         
            +
                assert_equal(@cache_object.order_num,object.order_num)
         
     | 
| 
      
 164 
     | 
    
         
            +
                assert_equal(@cache_object.is_pick,object.is_pick)
         
     | 
| 
      
 165 
     | 
    
         
            +
                assert_equal(@cache_object.rich_intro,object.rich_intro)
         
     | 
| 
      
 166 
     | 
    
         
            +
                assert_equal(@cache_object.short_intro,object.short_intro)
         
     | 
| 
      
 167 
     | 
    
         
            +
                assert_equal(@cache_object.comment_content,object.comment_content)
         
     | 
| 
      
 168 
     | 
    
         
            +
                assert_equal(@cache_object.comment_id,object.comment_id)
         
     | 
| 
      
 169 
     | 
    
         
            +
                assert_equal(@cache_object.dig_status,object.dig_status)
         
     | 
| 
      
 170 
     | 
    
         
            +
                assert_equal(@cache_object.approved_at,object.approved_at)
         
     | 
| 
      
 171 
     | 
    
         
            +
                assert_equal(@cache_object.is_deleted,object.is_deleted)
         
     | 
| 
      
 172 
     | 
    
         
            +
                assert_equal(@cache_object.mp3size,object.mp3size)
         
     | 
| 
      
 173 
     | 
    
         
            +
                assert_equal(@cache_object.mp3size_32,object.mp3size_32)
         
     | 
| 
      
 174 
     | 
    
         
            +
                assert_equal(@cache_object.mp3size_64,object.mp3size_64)
         
     | 
| 
      
 175 
     | 
    
         
            +
                assert_equal(@cache_object.waveform,object.waveform)
         
     | 
| 
      
 176 
     | 
    
         
            +
                assert_equal(@cache_object.upload_id,object.upload_id)
         
     | 
| 
      
 177 
     | 
    
         
            +
                assert_equal(@cache_object.updated_at,object.updated_at)
         
     | 
| 
      
 178 
     | 
    
         
            +
                assert_equal(@cache_object.created_at,object.created_at)
         
     | 
| 
      
 179 
     | 
    
         
            +
                assert_equal(@cache_object.source_url,object.source_url)
         
     | 
| 
      
 180 
     | 
    
         
            +
                assert_equal(@cache_object.status,object.status)
         
     | 
| 
      
 181 
     | 
    
         
            +
                assert_equal(@cache_object.explore_height,object.explore_height)
         
     | 
| 
      
 182 
     | 
    
         
            +
                assert_equal(@cache_object.id,object.id)
         
     | 
| 
      
 183 
     | 
    
         
            +
              end
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
              def test_get_set_benchmark
         
     | 
| 
      
 186 
     | 
    
         
            +
                @object_cache.evict(1)
         
     | 
| 
      
 187 
     | 
    
         
            +
                times = 1000
         
     | 
| 
      
 188 
     | 
    
         
            +
                start = Time.now
         
     | 
| 
      
 189 
     | 
    
         
            +
                for i in 1 .. times do
         
     | 
| 
      
 190 
     | 
    
         
            +
                  @object_cache.put(@cache_object)
         
     | 
| 
      
 191 
     | 
    
         
            +
                end
         
     | 
| 
      
 192 
     | 
    
         
            +
                stop = Time.now
         
     | 
| 
      
 193 
     | 
    
         
            +
                puts "#{times} times put operation total use #{stop-start} seconds"
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
                start = Time.now
         
     | 
| 
      
 196 
     | 
    
         
            +
                for i in 1 .. times do
         
     | 
| 
      
 197 
     | 
    
         
            +
                  @object_cache.get(1)
         
     | 
| 
      
 198 
     | 
    
         
            +
                end
         
     | 
| 
      
 199 
     | 
    
         
            +
                stop = Time.now
         
     | 
| 
      
 200 
     | 
    
         
            +
                puts "#{times} times get operation total use #{stop-start} seconds"
         
     | 
| 
      
 201 
     | 
    
         
            +
              end
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
              def test_mget_mset
         
     | 
| 
      
 204 
     | 
    
         
            +
                result = @object_cache.multi_put(@cache_objects)
         
     | 
| 
      
 205 
     | 
    
         
            +
                for i in 0 .. result.length - 1 do
         
     | 
| 
      
 206 
     | 
    
         
            +
                  success = false
         
     | 
| 
      
 207 
     | 
    
         
            +
                  if result[i] == "OK" or result[i] == true
         
     | 
| 
      
 208 
     | 
    
         
            +
                    success = true
         
     | 
| 
      
 209 
     | 
    
         
            +
                  end
         
     | 
| 
      
 210 
     | 
    
         
            +
                  assert_equal(true,success)
         
     | 
| 
      
 211 
     | 
    
         
            +
                end
         
     | 
| 
      
 212 
     | 
    
         
            +
                objects = @object_cache.multi_get(@keys)
         
     | 
| 
      
 213 
     | 
    
         
            +
                assert_equal(@cache_objects.length, objects.length)
         
     | 
| 
      
 214 
     | 
    
         
            +
                for i in 0 .. @cache_objects.length - 1 do
         
     | 
| 
      
 215 
     | 
    
         
            +
                  assert_equal(Time.name,objects[i].created_at.class.name)
         
     | 
| 
      
 216 
     | 
    
         
            +
                  assert_equal(Time.name,objects[i].updated_at.class.name)
         
     | 
| 
      
 217 
     | 
    
         
            +
                  assert_equal(Time.name,objects[i].approved_at.class.name)
         
     | 
| 
      
 218 
     | 
    
         
            +
                  assert_equal(FalseClass.name,objects[i].is_crawler.class.name)
         
     | 
| 
      
 219 
     | 
    
         
            +
                  assert_equal(TrueClass.name,objects[i].is_public.class.name)
         
     | 
| 
      
 220 
     | 
    
         
            +
                  assert_equal(Fixnum.name,objects[i].mp3size.class.name)
         
     | 
| 
      
 221 
     | 
    
         
            +
                  assert_equal(BigDecimal.name,objects[i].longitude.class.name)
         
     | 
| 
      
 222 
     | 
    
         
            +
                  assert_equal(Bignum.name,objects[i].track_id.class.name)
         
     | 
| 
      
 223 
     | 
    
         
            +
                  assert_equal(String.name,objects[i].play_path.class.name)
         
     | 
| 
      
 224 
     | 
    
         
            +
             
     | 
| 
      
 225 
     | 
    
         
            +
                  #VALUE assert
         
     | 
| 
      
 226 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].track_id,objects[i].track_id)
         
     | 
| 
      
 227 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].track_uid,objects[i].track_uid)
         
     | 
| 
      
 228 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].track_upload_source,objects[i].track_upload_source)
         
     | 
| 
      
 229 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].op_type,objects[i].op_type)
         
     | 
| 
      
 230 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].is_publish,objects[i].is_publish)
         
     | 
| 
      
 231 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].upload_source,objects[i].upload_source)
         
     | 
| 
      
 232 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].uid,objects[i].uid)
         
     | 
| 
      
 233 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].nickname,objects[i].nickname)
         
     | 
| 
      
 234 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].avatar_path,objects[i].avatar_path)
         
     | 
| 
      
 235 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].is_v,objects[i].is_v)
         
     | 
| 
      
 236 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].human_category_id,objects[i].human_category_id)
         
     | 
| 
      
 237 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].title,objects[i].title)
         
     | 
| 
      
 238 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].intro,objects[i].intro)
         
     | 
| 
      
 239 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].user_source,objects[i].user_source)
         
     | 
| 
      
 240 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].category_id,objects[i].category_id)
         
     | 
| 
      
 241 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].duration,objects[i].duration)
         
     | 
| 
      
 242 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].play_path,objects[i].play_path)
         
     | 
| 
      
 243 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].play_path_32,objects[i].play_path_32)
         
     | 
| 
      
 244 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].play_path_64,objects[i].play_path_64)
         
     | 
| 
      
 245 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].play_path_128,objects[i].play_path_128)
         
     | 
| 
      
 246 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].transcode_state,objects[i].transcode_state)
         
     | 
| 
      
 247 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].download_path,objects[i].download_path)
         
     | 
| 
      
 248 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].cover_path,objects[i].cover_path)
         
     | 
| 
      
 249 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].album_id,objects[i].album_id)
         
     | 
| 
      
 250 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].album_title,objects[i].album_title)
         
     | 
| 
      
 251 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].album_cover_path,objects[i].album_cover_path)
         
     | 
| 
      
 252 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].tags,objects[i].tags)
         
     | 
| 
      
 253 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].ignore_tags,objects[i].ignore_tags)
         
     | 
| 
      
 254 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].extra_tags,objects[i].extra_tags)
         
     | 
| 
      
 255 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].singer,objects[i].singer)
         
     | 
| 
      
 256 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].singer_category,objects[i].singer_category)
         
     | 
| 
      
 257 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].author,objects[i].author)
         
     | 
| 
      
 258 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].composer,objects[i].composer)
         
     | 
| 
      
 259 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].arrangement,objects[i].arrangement)
         
     | 
| 
      
 260 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].post_production,objects[i].post_production)
         
     | 
| 
      
 261 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].lyric_path,objects[i].lyric_path)
         
     | 
| 
      
 262 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].language,objects[i].language)
         
     | 
| 
      
 263 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].lyric,objects[i].lyric)
         
     | 
| 
      
 264 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].resinger,objects[i].resinger)
         
     | 
| 
      
 265 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].announcer,objects[i].announcer)
         
     | 
| 
      
 266 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].is_public,objects[i].is_public)
         
     | 
| 
      
 267 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].access_password,objects[i].access_password)
         
     | 
| 
      
 268 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].allow_download,objects[i].allow_download)
         
     | 
| 
      
 269 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].allow_comment,objects[i].allow_comment)
         
     | 
| 
      
 270 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].is_crawler,objects[i].is_crawler)
         
     | 
| 
      
 271 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].inet_aton_ip,objects[i].inet_aton_ip)
         
     | 
| 
      
 272 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].longitude,objects[i].longitude)
         
     | 
| 
      
 273 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].latitude,objects[i].latitude)
         
     | 
| 
      
 274 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].music_category,objects[i].music_category)
         
     | 
| 
      
 275 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].order_num,objects[i].order_num)
         
     | 
| 
      
 276 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].is_pick,objects[i].is_pick)
         
     | 
| 
      
 277 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].rich_intro,objects[i].rich_intro)
         
     | 
| 
      
 278 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].short_intro,objects[i].short_intro)
         
     | 
| 
      
 279 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].comment_content,objects[i].comment_content)
         
     | 
| 
      
 280 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].comment_id,objects[i].comment_id)
         
     | 
| 
      
 281 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].dig_status,objects[i].dig_status)
         
     | 
| 
      
 282 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].approved_at,objects[i].approved_at)
         
     | 
| 
      
 283 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].is_deleted,objects[i].is_deleted)
         
     | 
| 
      
 284 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].mp3size,objects[i].mp3size)
         
     | 
| 
      
 285 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].mp3size_32,objects[i].mp3size_32)
         
     | 
| 
      
 286 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].mp3size_64,objects[i].mp3size_64)
         
     | 
| 
      
 287 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].waveform,objects[i].waveform)
         
     | 
| 
      
 288 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].upload_id,objects[i].upload_id)
         
     | 
| 
      
 289 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].updated_at,objects[i].updated_at)
         
     | 
| 
      
 290 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].created_at,objects[i].created_at)
         
     | 
| 
      
 291 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].source_url,objects[i].source_url)
         
     | 
| 
      
 292 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].status,objects[i].status)
         
     | 
| 
      
 293 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].explore_height,objects[i].explore_height)
         
     | 
| 
      
 294 
     | 
    
         
            +
                  assert_equal(@cache_objects[i].id,objects[i].id)
         
     | 
| 
      
 295 
     | 
    
         
            +
                end
         
     | 
| 
      
 296 
     | 
    
         
            +
              end
         
     | 
| 
      
 297 
     | 
    
         
            +
             
     | 
| 
      
 298 
     | 
    
         
            +
              def test_mget_mset_benchmark
         
     | 
| 
      
 299 
     | 
    
         
            +
                @object_cache.batch_evict @keys
         
     | 
| 
      
 300 
     | 
    
         
            +
             
     | 
| 
      
 301 
     | 
    
         
            +
                times = 1000
         
     | 
| 
      
 302 
     | 
    
         
            +
                start = Time.now
         
     | 
| 
      
 303 
     | 
    
         
            +
                for i in 1 .. times do
         
     | 
| 
      
 304 
     | 
    
         
            +
                  @object_cache.multi_put(@cache_objects)
         
     | 
| 
      
 305 
     | 
    
         
            +
                end
         
     | 
| 
      
 306 
     | 
    
         
            +
                stop = Time.now
         
     | 
| 
      
 307 
     | 
    
         
            +
                puts "#{times} times multi_put operation total use #{stop-start} seconds"
         
     | 
| 
      
 308 
     | 
    
         
            +
             
     | 
| 
      
 309 
     | 
    
         
            +
                start = Time.now
         
     | 
| 
      
 310 
     | 
    
         
            +
                for i in 1 .. times do
         
     | 
| 
      
 311 
     | 
    
         
            +
                  @object_cache.multi_get(@keys)
         
     | 
| 
      
 312 
     | 
    
         
            +
                end
         
     | 
| 
      
 313 
     | 
    
         
            +
                stop = Time.now
         
     | 
| 
      
 314 
     | 
    
         
            +
                puts "#{times} times multi_get operation total use #{stop-start} seconds"
         
     | 
| 
      
 315 
     | 
    
         
            +
              end
         
     | 
| 
      
 316 
     | 
    
         
            +
             
     | 
| 
      
 317 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 318 
     | 
    
         
            +
                super
         
     | 
| 
      
 319 
     | 
    
         
            +
                puts "teardown"
         
     | 
| 
      
 320 
     | 
    
         
            +
              end
         
     | 
| 
      
 321 
     | 
    
         
            +
            end
         
     | 
| 
      
 322 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,48 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            $:.unshift File.expand_path("../../lib", __FILE__)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "test/unit"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "xunch"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            class RBTreeTest < Test::Unit::TestCase
         
     | 
| 
      
 7 
     | 
    
         
            +
              include Test::Unit::Assertions
         
     | 
| 
      
 8 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 9 
     | 
    
         
            +
                super
         
     | 
| 
      
 10 
     | 
    
         
            +
                puts "setup"
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              def test_rb_tree
         
     | 
| 
      
 14 
     | 
    
         
            +
                tree = Xunch::RBTree.new
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                tree.put(1,"1")
         
     | 
| 
      
 17 
     | 
    
         
            +
                tree.put(3,"3")
         
     | 
| 
      
 18 
     | 
    
         
            +
                tree.put(5,"5")
         
     | 
| 
      
 19 
     | 
    
         
            +
                tree.put(7,"7")
         
     | 
| 
      
 20 
     | 
    
         
            +
                tree.put(9,"9")
         
     | 
| 
      
 21 
     | 
    
         
            +
                tree.put(11,"11")
         
     | 
| 
      
 22 
     | 
    
         
            +
                puts tree.size
         
     | 
| 
      
 23 
     | 
    
         
            +
                # tree.p
         
     | 
| 
      
 24 
     | 
    
         
            +
                # puts tree.get(1)
         
     | 
| 
      
 25 
     | 
    
         
            +
                # puts tree.root.inspect
         
     | 
| 
      
 26 
     | 
    
         
            +
                # puts tree.root.left
         
     | 
| 
      
 27 
     | 
    
         
            +
                # puts tree.root.right
         
     | 
| 
      
 28 
     | 
    
         
            +
                # puts tree.root.right.left
         
     | 
| 
      
 29 
     | 
    
         
            +
                # puts tree.root.right.right
         
     | 
| 
      
 30 
     | 
    
         
            +
                puts tree.first_node.inspect
         
     | 
| 
      
 31 
     | 
    
         
            +
                puts tree.last_node.inspect
         
     | 
| 
      
 32 
     | 
    
         
            +
                puts tree.ceiling_node(2).inspect
         
     | 
| 
      
 33 
     | 
    
         
            +
                puts tree.floor_node(2).inspect
         
     | 
| 
      
 34 
     | 
    
         
            +
                puts tree.ceiling_node(5).inspect
         
     | 
| 
      
 35 
     | 
    
         
            +
                puts tree.floor_node(5).inspect
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                puts tree.lower_node(6).inspect
         
     | 
| 
      
 38 
     | 
    
         
            +
                puts tree.higher_node(6).inspect
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                puts tree.lower_node(9).inspect
         
     | 
| 
      
 41 
     | 
    
         
            +
                puts tree.higher_node(9).inspect
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 45 
     | 
    
         
            +
                super
         
     | 
| 
      
 46 
     | 
    
         
            +
                puts "teardown"
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,54 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'redis'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'hiredis'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "test/unit"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'bigdecimal'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'time'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            class ConsistencyhashTest < Test::Unit::TestCase
         
     | 
| 
      
 8 
     | 
    
         
            +
              include Test::Unit::Assertions
         
     | 
| 
      
 9 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 10 
     | 
    
         
            +
                super
         
     | 
| 
      
 11 
     | 
    
         
            +
                puts "setup"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              def test_consistency_hash
         
     | 
| 
      
 15 
     | 
    
         
            +
                redis = Redis.new(:host => "192.168.1.174", :port => 6379, :password => "jredis123456", :driver => :hiredis)
         
     | 
| 
      
 16 
     | 
    
         
            +
                redis.select 10
         
     | 
| 
      
 17 
     | 
    
         
            +
                hash = {
         
     | 
| 
      
 18 
     | 
    
         
            +
                  "field1" => "value1",
         
     | 
| 
      
 19 
     | 
    
         
            +
                  "field2" => BigDecimal.new("1231312321.1545727"),
         
     | 
| 
      
 20 
     | 
    
         
            +
                  "field3" => Time.new.to_datetime,
         
     | 
| 
      
 21 
     | 
    
         
            +
                  "field4" => 123432432141324321432432,
         
     | 
| 
      
 22 
     | 
    
         
            +
                  "field5" => 54444.4545,
         
     | 
| 
      
 23 
     | 
    
         
            +
                  "field6" => 12313123,
         
     | 
| 
      
 24 
     | 
    
         
            +
                  # "field7" => "value7",
         
     | 
| 
      
 25 
     | 
    
         
            +
                  # "field8" => "value8",
         
     | 
| 
      
 26 
     | 
    
         
            +
                  # "field9" => "value9",
         
     | 
| 
      
 27 
     | 
    
         
            +
                  # "field10" => "value10",
         
     | 
| 
      
 28 
     | 
    
         
            +
                  # "field11" => "value11",
         
     | 
| 
      
 29 
     | 
    
         
            +
                  # "field12" => "value12",
         
     | 
| 
      
 30 
     | 
    
         
            +
                  # "field13" => "value13",
         
     | 
| 
      
 31 
     | 
    
         
            +
                  # "field14" => "value14",
         
     | 
| 
      
 32 
     | 
    
         
            +
                  # "field15" => "value15",
         
     | 
| 
      
 33 
     | 
    
         
            +
                  # "field16" => "value16",
         
     | 
| 
      
 34 
     | 
    
         
            +
                  # "field17" => "value17",
         
     | 
| 
      
 35 
     | 
    
         
            +
                  # "field18" => "value18",
         
     | 
| 
      
 36 
     | 
    
         
            +
                  # "field19" => "value19",
         
     | 
| 
      
 37 
     | 
    
         
            +
                  # "field20" => "value20",
         
     | 
| 
      
 38 
     | 
    
         
            +
                }
         
     | 
| 
      
 39 
     | 
    
         
            +
                start = Time.new
         
     | 
| 
      
 40 
     | 
    
         
            +
                for i in 0 ..10000 do
         
     | 
| 
      
 41 
     | 
    
         
            +
                  redis.pipelined do
         
     | 
| 
      
 42 
     | 
    
         
            +
                    redis.mapped_hmset("key", hash)
         
     | 
| 
      
 43 
     | 
    
         
            +
                    redis.pexpire("key",10000)
         
     | 
| 
      
 44 
     | 
    
         
            +
                  end
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
                stop = Time.new
         
     | 
| 
      
 47 
     | 
    
         
            +
                puts stop - start
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 51 
     | 
    
         
            +
                super
         
     | 
| 
      
 52 
     | 
    
         
            +
                puts "teardown"
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     |