moneta 1.0.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +425 -0
- data/.gitignore +3 -0
- data/.rspec +4 -0
- data/.rubocop.yml +194 -0
- data/.yardopts +6 -1
- data/CHANGES +88 -0
- data/CONTRIBUTORS +10 -2
- data/Gemfile +198 -76
- data/LICENSE +1 -1
- data/README.md +181 -83
- data/SPEC.md +70 -0
- data/feature_matrix.yaml +227 -0
- data/lib/action_dispatch/middleware/session/moneta_store.rb +1 -0
- data/lib/active_support/cache/moneta_store.rb +102 -6
- data/lib/moneta/adapter.rb +52 -0
- data/lib/moneta/adapters/activerecord.rb +284 -99
- data/lib/moneta/adapters/activesupportcache.rb +120 -0
- data/lib/moneta/adapters/cassandra.rb +303 -51
- data/lib/moneta/adapters/client.rb +72 -23
- data/lib/moneta/adapters/couch.rb +353 -49
- data/lib/moneta/adapters/datamapper.rb +11 -5
- data/lib/moneta/adapters/daybreak.rb +31 -20
- data/lib/moneta/adapters/dbm.rb +10 -16
- data/lib/moneta/adapters/file.rb +34 -13
- data/lib/moneta/adapters/fog.rb +5 -6
- data/lib/moneta/adapters/gdbm.rb +10 -16
- data/lib/moneta/adapters/hbase.rb +11 -13
- data/lib/moneta/adapters/kyotocabinet.rb +78 -17
- data/lib/moneta/adapters/leveldb.rb +35 -15
- data/lib/moneta/adapters/lmdb.rb +47 -23
- data/lib/moneta/adapters/localmemcache.rb +7 -13
- data/lib/moneta/adapters/lruhash.rb +45 -48
- data/lib/moneta/adapters/memcached/dalli.rb +67 -30
- data/lib/moneta/adapters/memcached/native.rb +33 -30
- data/lib/moneta/adapters/memcached.rb +1 -0
- data/lib/moneta/adapters/memory.rb +7 -7
- data/lib/moneta/adapters/mongo.rb +265 -6
- data/lib/moneta/adapters/null.rb +1 -2
- data/lib/moneta/adapters/pstore.rb +68 -25
- data/lib/moneta/adapters/redis.rb +101 -32
- data/lib/moneta/adapters/restclient.rb +17 -16
- data/lib/moneta/adapters/riak.rb +10 -11
- data/lib/moneta/adapters/sdbm.rb +10 -16
- data/lib/moneta/adapters/sequel/mysql.rb +66 -0
- data/lib/moneta/adapters/sequel/postgres.rb +80 -0
- data/lib/moneta/adapters/sequel/postgres_hstore.rb +240 -0
- data/lib/moneta/adapters/sequel/sqlite.rb +57 -0
- data/lib/moneta/adapters/sequel.rb +253 -52
- data/lib/moneta/adapters/sqlite.rb +103 -23
- data/lib/moneta/adapters/tdb.rb +21 -12
- data/lib/moneta/adapters/tokyocabinet.rb +24 -16
- data/lib/moneta/adapters/tokyotyrant.rb +49 -28
- data/lib/moneta/adapters/yaml.rb +1 -5
- data/lib/moneta/builder.rb +2 -3
- data/lib/moneta/cache.rb +11 -1
- data/lib/moneta/config.rb +101 -0
- data/lib/moneta/create_support.rb +21 -0
- data/lib/moneta/dbm_adapter.rb +31 -0
- data/lib/moneta/defaults.rb +320 -0
- data/lib/moneta/each_key_support.rb +27 -0
- data/lib/moneta/enumerable.rb +38 -0
- data/lib/moneta/expires.rb +112 -11
- data/lib/moneta/expires_support.rb +59 -0
- data/lib/moneta/fallback.rb +84 -0
- data/lib/moneta/hash_adapter.rb +68 -0
- data/lib/moneta/increment_support.rb +16 -0
- data/lib/moneta/lock.rb +26 -2
- data/lib/moneta/logger.rb +2 -2
- data/lib/moneta/nil_values.rb +35 -0
- data/lib/moneta/option_support.rb +51 -0
- data/lib/moneta/optionmerger.rb +0 -1
- data/lib/moneta/pool.rb +339 -28
- data/lib/moneta/proxy.rb +75 -2
- data/lib/moneta/server.rb +230 -68
- data/lib/moneta/shared.rb +36 -14
- data/lib/moneta/stack.rb +7 -7
- data/lib/moneta/synchronize.rb +5 -11
- data/lib/moneta/transformer/config.rb +64 -42
- data/lib/moneta/transformer/helper/bson.rb +7 -14
- data/lib/moneta/transformer/helper.rb +5 -5
- data/lib/moneta/transformer.rb +217 -23
- data/lib/moneta/utils.rb +3 -9
- data/lib/moneta/version.rb +1 -1
- data/lib/moneta/weak_each_key.rb +72 -0
- data/lib/moneta/wrapper.rb +30 -0
- data/lib/moneta.rb +29 -10
- data/lib/rack/cache/moneta.rb +13 -11
- data/lib/rack/moneta_rest.rb +2 -2
- data/lib/rack/session/moneta.rb +3 -4
- data/moneta.gemspec +19 -4
- data/script/benchmarks +311 -100
- data/script/contributors +11 -6
- data/script/parallel-tests +58 -83
- data/script/start-couchdb +27 -0
- data/script/start-hbase +47 -0
- data/script/start-services +5 -6
- data/script/update-feature-matrix +148 -0
- data/spec/active_support/cache_moneta_store_spec.rb +129 -106
- data/spec/features/concurrent_create.rb +42 -0
- data/spec/features/concurrent_increment.rb +39 -0
- data/spec/features/create.rb +25 -0
- data/spec/features/create_expires.rb +19 -0
- data/spec/features/default_expires.rb +14 -0
- data/spec/features/each_key.rb +119 -0
- data/spec/features/expires.rb +296 -0
- data/spec/features/features.rb +16 -0
- data/spec/features/increment.rb +98 -0
- data/spec/features/marshallable_key.rb +43 -0
- data/spec/features/marshallable_value.rb +7 -0
- data/spec/features/multiprocess.rb +8 -0
- data/spec/features/not_create.rb +7 -0
- data/spec/features/not_each_key.rb +7 -0
- data/spec/features/not_increment.rb +13 -0
- data/spec/features/not_persist.rb +9 -0
- data/spec/features/null.rb +66 -0
- data/spec/features/persist.rb +14 -0
- data/spec/features/returndifferent.rb +9 -0
- data/spec/features/returnsame.rb +9 -0
- data/spec/features/store.rb +261 -0
- data/spec/features/store_large.rb +13 -0
- data/spec/features/transform_value.rb +44 -0
- data/spec/features/transform_value_expires.rb +41 -0
- data/spec/helper.rb +345 -78
- data/spec/moneta/adapters/activerecord/adapter_activerecord_existing_connection_spec.rb +61 -0
- data/spec/moneta/adapters/activerecord/adapter_activerecord_spec.rb +126 -0
- data/spec/moneta/adapters/activerecord/standard_activerecord_spec.rb +21 -0
- data/spec/moneta/adapters/activerecord/standard_activerecord_with_expires_spec.rb +27 -0
- data/spec/moneta/adapters/activesupportcache/adapter_activesupportcache_spec.rb +54 -0
- data/spec/moneta/adapters/activesupportcache/adapter_activesupportcache_with_default_expires_spec.rb +54 -0
- data/spec/moneta/adapters/activesupportcache/standard_activesupportcache_spec.rb +14 -0
- data/spec/moneta/adapters/cassandra/adapter_cassandra_spec.rb +17 -0
- data/spec/moneta/adapters/cassandra/adapter_cassandra_with_default_expires_spec.rb +18 -0
- data/spec/moneta/adapters/cassandra/helper.rb +18 -0
- data/spec/moneta/adapters/cassandra/standard_cassandra_spec.rb +18 -0
- data/spec/moneta/adapters/client/adapter_client_spec.rb +11 -0
- data/spec/moneta/adapters/client/client_helper.rb +25 -0
- data/spec/moneta/adapters/client/standard_client_tcp_spec.rb +23 -0
- data/spec/moneta/adapters/client/standard_client_unix_spec.rb +28 -0
- data/spec/moneta/adapters/cookie/adapter_cookie_spec.rb +7 -0
- data/spec/moneta/adapters/couch/adapter_couch_spec.rb +204 -0
- data/spec/moneta/adapters/couch/standard_couch_spec.rb +15 -0
- data/spec/moneta/adapters/couch/standard_couch_with_expires_spec.rb +19 -0
- data/spec/moneta/adapters/datamapper/adapter_datamapper_spec.rb +60 -0
- data/spec/moneta/adapters/datamapper/standard_datamapper_spec.rb +21 -0
- data/spec/moneta/adapters/datamapper/standard_datamapper_with_expires_spec.rb +26 -0
- data/spec/moneta/adapters/datamapper/standard_datamapper_with_repository_spec.rb +22 -0
- data/spec/moneta/adapters/daybreak/adapter_daybreak_spec.rb +7 -0
- data/spec/moneta/adapters/daybreak/standard_daybreak_spec.rb +7 -0
- data/spec/moneta/adapters/daybreak/standard_daybreak_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/dbm/adapter_dbm_spec.rb +7 -0
- data/spec/moneta/adapters/dbm/standard_dbm_spec.rb +7 -0
- data/spec/moneta/adapters/dbm/standard_dbm_with_expires_spec.rb +12 -0
- data/spec/moneta/adapters/faraday_helper.rb +10 -0
- data/spec/moneta/adapters/file/adapter_file_spec.rb +7 -0
- data/spec/moneta/adapters/file/standard_file_spec.rb +7 -0
- data/spec/moneta/adapters/file/standard_file_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/fog/adapter_fog_spec.rb +16 -0
- data/spec/moneta/adapters/fog/standard_fog_spec.rb +15 -0
- data/spec/moneta/adapters/fog/standard_fog_with_expires_spec.rb +20 -0
- data/spec/moneta/adapters/gdbm/adapter_gdbm_spec.rb +7 -0
- data/spec/moneta/adapters/gdbm/standard_gdbm_spec.rb +7 -0
- data/spec/moneta/adapters/gdbm/standard_gdbm_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/hashfile/standard_hashfile_spec.rb +7 -0
- data/spec/moneta/adapters/hashfile/standard_hashfile_with_expires_spec.rb +12 -0
- data/spec/moneta/adapters/hbase/adapter_hbase_spec.rb +7 -0
- data/spec/moneta/adapters/hbase/standard_hbase_spec.rb +4 -0
- data/spec/moneta/adapters/hbase/standard_hbase_with_expires_spec.rb +8 -0
- data/spec/moneta/adapters/kyotocabinet/adapter_kyotocabinet_spec.rb +7 -0
- data/spec/moneta/adapters/kyotocabinet/standard_kyotocabinet_spec.rb +7 -0
- data/spec/moneta/adapters/kyotocabinet/standard_kyotocabinet_with_expires_spec.rb +14 -0
- data/spec/moneta/adapters/leveldb/adapter_leveldb_spec.rb +7 -0
- data/spec/moneta/adapters/leveldb/standard_leveldb_spec.rb +7 -0
- data/spec/moneta/adapters/leveldb/standard_leveldb_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/lmdb/adapter_lmdb_spec.rb +7 -0
- data/spec/moneta/adapters/lmdb/adapter_lmdb_with_db_spec.rb +7 -0
- data/spec/moneta/adapters/lmdb/standard_lmdb_spec.rb +7 -0
- data/spec/moneta/adapters/lmdb/standard_lmdb_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/localmemcache/adapter_localmemcache_spec.rb +7 -0
- data/spec/moneta/adapters/localmemcache/standard_localmemcache_spec.rb +7 -0
- data/spec/moneta/adapters/localmemcache/standard_localmemcache_with_expires_spec.rb +11 -0
- data/spec/moneta/{adapter_lruhash_spec.rb → adapters/lruhash/adapter_lruhash_spec.rb} +15 -33
- data/spec/moneta/adapters/lruhash/standard_lruhash_spec.rb +4 -0
- data/spec/moneta/adapters/lruhash/standard_lruhash_with_expires_spec.rb +8 -0
- data/spec/moneta/adapters/memcached/adapter_memcached_spec.rb +13 -0
- data/spec/moneta/adapters/memcached/dalli/adapter_memcached_dalli_spec.rb +25 -0
- data/spec/moneta/adapters/memcached/dalli/standard_memcached_dalli_spec.rb +11 -0
- data/spec/moneta/adapters/memcached/native/adapter_memcached_native_spec.rb +25 -0
- data/spec/moneta/adapters/memcached/native/standard_memcached_native_spec.rb +11 -0
- data/spec/moneta/adapters/memcached/standard_memcached_spec.rb +17 -0
- data/spec/moneta/adapters/memcached_helper.rb +20 -0
- data/spec/moneta/adapters/memory/adapter_memory_spec.rb +7 -0
- data/spec/moneta/adapters/memory/standard_memory_spec.rb +4 -0
- data/spec/moneta/adapters/memory/standard_memory_with_compress_spec.rb +9 -0
- data/spec/moneta/adapters/memory/standard_memory_with_expires_spec.rb +8 -0
- data/spec/moneta/adapters/memory/standard_memory_with_json_key_serializer_spec.rb +4 -0
- data/spec/moneta/adapters/memory/standard_memory_with_json_serializer_spec.rb +9 -0
- data/spec/moneta/adapters/memory/standard_memory_with_json_value_serializer_spec.rb +9 -0
- data/spec/moneta/adapters/memory/standard_memory_with_prefix_spec.rb +41 -0
- data/spec/moneta/adapters/memory/standard_memory_with_snappy_compress_spec.rb +9 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_spec.rb +41 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_with_default_expires_spec.rb +14 -0
- data/spec/moneta/adapters/mongo/standard_mongo_spec.rb +7 -0
- data/spec/moneta/adapters/null/null_adapter_spec.rb +7 -0
- data/spec/moneta/adapters/null/standard_null_spec.rb +4 -0
- data/spec/moneta/adapters/pstore/adapter_pstore_spec.rb +7 -0
- data/spec/moneta/adapters/pstore/standard_pstore_spec.rb +9 -0
- data/spec/moneta/adapters/pstore/standard_pstore_with_expires_spec.rb +13 -0
- data/spec/moneta/adapters/redis/adapter_redis_spec.rb +20 -0
- data/spec/moneta/adapters/redis/standard_redis_spec.rb +14 -0
- data/spec/moneta/adapters/restclient/adapter_restclient_spec.rb +13 -0
- data/spec/moneta/adapters/restclient/helper.rb +12 -0
- data/spec/moneta/adapters/restclient/standard_restclient_spec.rb +13 -0
- data/spec/moneta/adapters/riak/adapter_riak_spec.rb +14 -0
- data/spec/moneta/adapters/riak/standard_riak_spec.rb +10 -0
- data/spec/moneta/adapters/riak/standard_riak_with_expires_spec.rb +14 -0
- data/spec/moneta/adapters/sdbm/adapter_sdbm_spec.rb +7 -0
- data/spec/moneta/adapters/sdbm/standard_sdbm_spec.rb +7 -0
- data/spec/moneta/adapters/sdbm/standard_sdbm_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/sequel/adapter_sequel_spec.rb +133 -0
- data/spec/moneta/adapters/sequel/helper.rb +80 -0
- data/spec/moneta/adapters/sequel/standard_sequel_spec.rb +8 -0
- data/spec/moneta/adapters/sequel/standard_sequel_with_expires_spec.rb +18 -0
- data/spec/moneta/adapters/sqlite/adapter_sqlite_spec.rb +7 -0
- data/spec/moneta/adapters/sqlite/standard_sqlite_spec.rb +7 -0
- data/spec/moneta/adapters/sqlite/standard_sqlite_with_expires_spec.rb +15 -0
- data/spec/moneta/adapters/tdb/adapter_tdb_spec.rb +7 -0
- data/spec/moneta/adapters/tdb/standard_tdb_spec.rb +7 -0
- data/spec/moneta/adapters/tdb/standard_tdb_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/tokyocabinet/adapter_tokyocabinet_bdb_spec.rb +7 -0
- data/spec/moneta/adapters/tokyocabinet/adapter_tokyocabinet_hdb_spec.rb +7 -0
- data/spec/moneta/adapters/tokyocabinet/standard_tokyocabinet_spec.rb +7 -0
- data/spec/moneta/adapters/tokyocabinet/standard_tokyocabinet_with_expires_spec.rb +11 -0
- data/spec/moneta/adapters/tokyotyrant/adapter_tokyotyrant_spec.rb +11 -0
- data/spec/moneta/adapters/tokyotyrant/helper.rb +12 -0
- data/spec/moneta/adapters/tokyotyrant/standard_tokyotyrant_spec.rb +7 -0
- data/spec/moneta/adapters/tokyotyrant/standard_tokyotyrant_with_expires_spec.rb +12 -0
- data/spec/moneta/adapters/yaml/adapter_yaml_spec.rb +7 -0
- data/spec/moneta/adapters/yaml/standard_yaml_spec.rb +9 -0
- data/spec/moneta/adapters/yaml/standard_yaml_with_expires_spec.rb +13 -0
- data/spec/moneta/builder_spec.rb +22 -1
- data/spec/moneta/config_spec.rb +219 -0
- data/spec/moneta/mutex_spec.rb +6 -23
- data/spec/moneta/proxies/cache/cache_file_memory_spec.rb +24 -0
- data/spec/moneta/proxies/cache/cache_memory_null_spec.rb +12 -0
- data/spec/moneta/proxies/enumerable/enumerable_spec.rb +26 -0
- data/spec/moneta/proxies/expires/expires_file_spec.rb +28 -0
- data/spec/moneta/proxies/expires/expires_memory_spec.rb +15 -0
- data/spec/moneta/proxies/expires/expires_memory_with_default_expires_spec.rb +16 -0
- data/spec/moneta/proxies/fallback/fallback_spec.rb +42 -0
- data/spec/moneta/proxies/lock/lock_spec.rb +10 -0
- data/spec/moneta/{optionmerger_spec.rb → proxies/optionmerger/optionmerger_spec.rb} +2 -18
- data/spec/moneta/proxies/pool/pool_spec.rb +353 -0
- data/spec/moneta/proxies/proxy/proxy_expires_memory_spec.rb +16 -0
- data/spec/moneta/proxies/shared/shared_tcp_spec.rb +59 -0
- data/spec/moneta/proxies/shared/shared_unix_spec.rb +58 -0
- data/spec/moneta/proxies/transformer/transformer_bencode_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_bert_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_bson_spec.rb +25 -0
- data/spec/moneta/proxies/transformer/transformer_bzip2_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_json_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_key_inspect_spec.rb +17 -0
- data/spec/moneta/proxies/transformer/transformer_key_marshal_spec.rb +17 -0
- data/spec/moneta/proxies/transformer/transformer_key_to_s_spec.rb +17 -0
- data/spec/moneta/proxies/transformer/transformer_key_yaml_spec.rb +17 -0
- data/spec/moneta/proxies/transformer/transformer_lz4_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_lzma_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_lzo_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_base64_spec.rb +20 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_city128_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_city32_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_city64_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_escape_spec.rb +21 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_hex_spec.rb +20 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_hmac_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_md5_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_md5_spread_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_prefix_base64_spec.rb +33 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_prefix_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_qp_spec.rb +20 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_rmd160_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_sha1_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_sha256_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_sha384_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_sha512_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_truncate_spec.rb +15 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_urlsafe_base64_spec.rb +20 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_uuencode_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_msgpack_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_ox_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_php_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_quicklz_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_snappy_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_tnet_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_value_marshal_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_value_yaml_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_yaml_spec.rb +19 -0
- data/spec/moneta/proxies/transformer/transformer_zlib_spec.rb +19 -0
- data/spec/moneta/proxies/weak_create/weak_create_spec.rb +21 -0
- data/spec/moneta/proxies/weak_each_key/weak_each_key_spec.rb +22 -0
- data/spec/moneta/proxies/weak_increment/weak_increment_spec.rb +21 -0
- data/spec/moneta/semaphore_spec.rb +6 -23
- data/spec/moneta/stack_file_memory_spec.rb +5 -29
- data/spec/moneta/stack_memory_file_spec.rb +5 -31
- data/spec/rack/session_moneta_spec.rb +44 -25
- data/spec/restserver.rb +44 -0
- data/{spec → test}/action_dispatch/fixtures/session_autoload_test/foo.rb +0 -0
- data/{spec/action_dispatch/session_moneta_store_spec.rb → test/action_dispatch/session_moneta_store_test.rb} +13 -5
- metadata +545 -369
- data/.travis.yml +0 -55
- data/lib/moneta/adapters/mongo/base.rb +0 -78
- data/lib/moneta/adapters/mongo/moped.rb +0 -107
- data/lib/moneta/adapters/mongo/official.rb +0 -117
- data/lib/moneta/mixins.rb +0 -343
- data/script/generate-specs +0 -2696
- data/script/install-kyotocabinet +0 -17
- data/spec/moneta/adapter_activerecord_exisiting_connection_spec.rb +0 -36
- data/spec/moneta/adapter_activerecord_spec.rb +0 -65
- data/spec/moneta/adapter_cassandra_spec.rb +0 -33
- data/spec/moneta/adapter_cassandra_with_default_expires_spec.rb +0 -34
- data/spec/moneta/adapter_client_spec.rb +0 -35
- data/spec/moneta/adapter_cookie_spec.rb +0 -30
- data/spec/moneta/adapter_couch_spec.rb +0 -36
- data/spec/moneta/adapter_datamapper_spec.rb +0 -64
- data/spec/moneta/adapter_daybreak_spec.rb +0 -31
- data/spec/moneta/adapter_dbm_spec.rb +0 -31
- data/spec/moneta/adapter_file_spec.rb +0 -34
- data/spec/moneta/adapter_fog_spec.rb +0 -37
- data/spec/moneta/adapter_gdbm_spec.rb +0 -31
- data/spec/moneta/adapter_hbase_spec.rb +0 -33
- data/spec/moneta/adapter_kyotocabinet_spec.rb +0 -31
- data/spec/moneta/adapter_leveldb_spec.rb +0 -31
- data/spec/moneta/adapter_lmdb_spec.rb +0 -32
- data/spec/moneta/adapter_lmdb_with_db_spec.rb +0 -32
- data/spec/moneta/adapter_localmemcache_spec.rb +0 -32
- data/spec/moneta/adapter_memcached_dalli_spec.rb +0 -36
- data/spec/moneta/adapter_memcached_dalli_with_default_expires_spec.rb +0 -37
- data/spec/moneta/adapter_memcached_native_spec.rb +0 -36
- data/spec/moneta/adapter_memcached_native_with_default_expires_spec.rb +0 -37
- data/spec/moneta/adapter_memcached_spec.rb +0 -36
- data/spec/moneta/adapter_memcached_with_default_expires_spec.rb +0 -37
- data/spec/moneta/adapter_memory_spec.rb +0 -184
- data/spec/moneta/adapter_mongo_moped_spec.rb +0 -64
- data/spec/moneta/adapter_mongo_moped_with_default_expires_spec.rb +0 -53
- data/spec/moneta/adapter_mongo_official_spec.rb +0 -64
- data/spec/moneta/adapter_mongo_official_with_default_expires_spec.rb +0 -53
- data/spec/moneta/adapter_mongo_spec.rb +0 -51
- data/spec/moneta/adapter_mongo_with_default_expires_spec.rb +0 -53
- data/spec/moneta/adapter_pstore_spec.rb +0 -250
- data/spec/moneta/adapter_redis_spec.rb +0 -36
- data/spec/moneta/adapter_redis_with_default_expires_spec.rb +0 -37
- data/spec/moneta/adapter_restclient_spec.rb +0 -33
- data/spec/moneta/adapter_riak_spec.rb +0 -36
- data/spec/moneta/adapter_sdbm_spec.rb +0 -30
- data/spec/moneta/adapter_sequel_spec.rb +0 -34
- data/spec/moneta/adapter_sqlite_spec.rb +0 -32
- data/spec/moneta/adapter_tdb_spec.rb +0 -31
- data/spec/moneta/adapter_tokyocabinet_bdb_spec.rb +0 -31
- data/spec/moneta/adapter_tokyocabinet_hdb_spec.rb +0 -31
- data/spec/moneta/adapter_tokyotyrant_spec.rb +0 -34
- data/spec/moneta/adapter_yaml_spec.rb +0 -57
- data/spec/moneta/cache_file_memory_spec.rb +0 -50
- data/spec/moneta/cache_memory_null_spec.rb +0 -35
- data/spec/moneta/expires_file_spec.rb +0 -78
- data/spec/moneta/expires_memory_spec.rb +0 -189
- data/spec/moneta/expires_memory_with_default_expires_spec.rb +0 -190
- data/spec/moneta/lock_spec.rb +0 -187
- data/spec/moneta/null_adapter_spec.rb +0 -86
- data/spec/moneta/pool_spec.rb +0 -38
- data/spec/moneta/proxy_expires_memory_spec.rb +0 -191
- data/spec/moneta/proxy_redis_spec.rb +0 -40
- data/spec/moneta/shared_tcp_spec.rb +0 -46
- data/spec/moneta/shared_unix_spec.rb +0 -46
- data/spec/moneta/standard_activerecord_spec.rb +0 -253
- data/spec/moneta/standard_activerecord_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_cassandra_spec.rb +0 -252
- data/spec/moneta/standard_client_tcp_spec.rb +0 -269
- data/spec/moneta/standard_client_unix_spec.rb +0 -254
- data/spec/moneta/standard_couch_spec.rb +0 -252
- data/spec/moneta/standard_couch_with_expires_spec.rb +0 -254
- data/spec/moneta/standard_datamapper_spec.rb +0 -254
- data/spec/moneta/standard_datamapper_with_expires_spec.rb +0 -256
- data/spec/moneta/standard_datamapper_with_repository_spec.rb +0 -254
- data/spec/moneta/standard_daybreak_spec.rb +0 -250
- data/spec/moneta/standard_daybreak_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_dbm_spec.rb +0 -250
- data/spec/moneta/standard_dbm_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_file_spec.rb +0 -253
- data/spec/moneta/standard_file_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_fog_spec.rb +0 -256
- data/spec/moneta/standard_fog_with_expires_spec.rb +0 -258
- data/spec/moneta/standard_gdbm_spec.rb +0 -250
- data/spec/moneta/standard_gdbm_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_hashfile_spec.rb +0 -253
- data/spec/moneta/standard_hashfile_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_hbase_spec.rb +0 -252
- data/spec/moneta/standard_hbase_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_kyotocabinet_spec.rb +0 -250
- data/spec/moneta/standard_kyotocabinet_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_leveldb_spec.rb +0 -250
- data/spec/moneta/standard_leveldb_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_lmdb_spec.rb +0 -251
- data/spec/moneta/standard_lmdb_with_expires_spec.rb +0 -253
- data/spec/moneta/standard_localmemcache_spec.rb +0 -251
- data/spec/moneta/standard_localmemcache_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_lruhash_spec.rb +0 -187
- data/spec/moneta/standard_lruhash_with_expires_spec.rb +0 -189
- data/spec/moneta/standard_memcached_dalli_spec.rb +0 -255
- data/spec/moneta/standard_memcached_native_spec.rb +0 -255
- data/spec/moneta/standard_memcached_spec.rb +0 -255
- data/spec/moneta/standard_memory_spec.rb +0 -187
- data/spec/moneta/standard_memory_with_compress_spec.rb +0 -187
- data/spec/moneta/standard_memory_with_expires_spec.rb +0 -189
- data/spec/moneta/standard_memory_with_json_key_serializer_spec.rb +0 -86
- data/spec/moneta/standard_memory_with_json_serializer_spec.rb +0 -49
- data/spec/moneta/standard_memory_with_json_value_serializer_spec.rb +0 -90
- data/spec/moneta/standard_memory_with_prefix_spec.rb +0 -187
- data/spec/moneta/standard_memory_with_snappy_compress_spec.rb +0 -187
- data/spec/moneta/standard_mongo_moped_spec.rb +0 -255
- data/spec/moneta/standard_mongo_official_spec.rb +0 -255
- data/spec/moneta/standard_mongo_spec.rb +0 -255
- data/spec/moneta/standard_null_spec.rb +0 -120
- data/spec/moneta/standard_pstore_spec.rb +0 -253
- data/spec/moneta/standard_pstore_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_redis_spec.rb +0 -255
- data/spec/moneta/standard_restclient_spec.rb +0 -252
- data/spec/moneta/standard_riak_spec.rb +0 -255
- data/spec/moneta/standard_riak_with_expires_spec.rb +0 -256
- data/spec/moneta/standard_sdbm_spec.rb +0 -249
- data/spec/moneta/standard_sdbm_with_expires_spec.rb +0 -251
- data/spec/moneta/standard_sequel_spec.rb +0 -253
- data/spec/moneta/standard_sequel_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_sqlite_spec.rb +0 -251
- data/spec/moneta/standard_sqlite_with_expires_spec.rb +0 -253
- data/spec/moneta/standard_tdb_spec.rb +0 -250
- data/spec/moneta/standard_tdb_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_tokyocabinet_spec.rb +0 -250
- data/spec/moneta/standard_tokyocabinet_with_expires_spec.rb +0 -252
- data/spec/moneta/standard_tokyotyrant_spec.rb +0 -253
- data/spec/moneta/standard_tokyotyrant_with_expires_spec.rb +0 -255
- data/spec/moneta/standard_yaml_spec.rb +0 -250
- data/spec/moneta/standard_yaml_with_expires_spec.rb +0 -252
- data/spec/moneta/transformer_bencode_spec.rb +0 -55
- data/spec/moneta/transformer_bert_spec.rb +0 -55
- data/spec/moneta/transformer_bson_spec.rb +0 -60
- data/spec/moneta/transformer_bzip2_spec.rb +0 -55
- data/spec/moneta/transformer_json_spec.rb +0 -55
- data/spec/moneta/transformer_key_inspect_spec.rb +0 -91
- data/spec/moneta/transformer_key_marshal_spec.rb +0 -191
- data/spec/moneta/transformer_key_to_s_spec.rb +0 -91
- data/spec/moneta/transformer_key_yaml_spec.rb +0 -191
- data/spec/moneta/transformer_lz4_spec.rb +0 -55
- data/spec/moneta/transformer_lzma_spec.rb +0 -55
- data/spec/moneta/transformer_lzo_spec.rb +0 -55
- data/spec/moneta/transformer_marshal_base64_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_city128_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_city32_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_city64_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_escape_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_hex_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_hmac_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_md5_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_md5_spread_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_prefix_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_qp_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_rmd160_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_sha1_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_sha256_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_sha384_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_sha512_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_spec.rb +0 -191
- data/spec/moneta/transformer_marshal_truncate_spec.rb +0 -194
- data/spec/moneta/transformer_marshal_uuencode_spec.rb +0 -194
- data/spec/moneta/transformer_msgpack_spec.rb +0 -55
- data/spec/moneta/transformer_ox_spec.rb +0 -191
- data/spec/moneta/transformer_php_spec.rb +0 -55
- data/spec/moneta/transformer_quicklz_spec.rb +0 -55
- data/spec/moneta/transformer_snappy_spec.rb +0 -55
- data/spec/moneta/transformer_tnet_spec.rb +0 -55
- data/spec/moneta/transformer_value_marshal_spec.rb +0 -191
- data/spec/moneta/transformer_value_yaml_spec.rb +0 -191
- data/spec/moneta/transformer_yaml_spec.rb +0 -191
- data/spec/moneta/transformer_zlib_spec.rb +0 -55
- data/spec/moneta/weak_create_spec.rb +0 -41
- data/spec/moneta/weak_increment_spec.rb +0 -41
- data/spec/monetaspecs.rb +0 -51267
- data/spec/quality_spec.rb +0 -51
data/script/benchmarks
CHANGED
@@ -4,6 +4,10 @@ $: << File.join(File.dirname(__FILE__), '..', 'lib')
|
|
4
4
|
require 'benchmark'
|
5
5
|
require 'moneta'
|
6
6
|
require 'fileutils'
|
7
|
+
require 'active_support'
|
8
|
+
require 'active_support/cache/moneta_store'
|
9
|
+
|
10
|
+
require_relative '../spec/restserver.rb'
|
7
11
|
|
8
12
|
class String
|
9
13
|
def random(n)
|
@@ -11,65 +15,244 @@ class String
|
|
11
15
|
end
|
12
16
|
end
|
13
17
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def mean
|
20
|
-
sum / size
|
21
|
-
end
|
18
|
+
def mean arr
|
19
|
+
arr.sum / arr.length
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
22
|
+
def stddev arr
|
23
|
+
m = mean(arr)
|
24
|
+
Math.sqrt(mean(arr.map {|s| (s - m) ** 2 }))
|
27
25
|
end
|
28
26
|
|
29
27
|
class MonetaBenchmarks
|
30
28
|
DIR = __FILE__ + '.tmp'
|
31
29
|
|
32
|
-
|
30
|
+
mysql_username = ENV['MONETA_MYSQL_USERNAME'] || 'root'
|
31
|
+
mysql_password = ENV['MONETA_MYSQL_PASSWORD']
|
32
|
+
mysql_database1 = ENV['MONETA_MYSQL_DATABSASE1'] || 'moneta'
|
33
|
+
mysql_database2 = ENV['MONETA_MYSQL_DATABSASE2'] || 'moneta2'
|
34
|
+
|
35
|
+
postgres_username = ENV['MONETA_POSTGRES_USERNAME'] || 'postgres'
|
36
|
+
postgres_database1 = ENV['MONETA_POSTGRES_DATABSASE1'] || 'moneta1'
|
37
|
+
postgres_database2 = ENV['MONETA_POSTGRES_DATABSASE1'] || 'moneta2'
|
38
|
+
|
39
|
+
couch_login = ENV['COUCH_LOGIN'] || 'admin'
|
40
|
+
couch_password = ENV['COUCH_PASSWORD'] || 'password'
|
41
|
+
|
42
|
+
STORES = [
|
33
43
|
# SDBM accepts only very short key/value pairs (1k for both)
|
34
|
-
|
44
|
+
{name: "SDBM", sizes: [:small], options: {file: "#{DIR}/sdbm"}},
|
35
45
|
# YAML is too slow
|
36
|
-
# YAML: {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
46
|
+
#{name: "YAML", options: {file: "#{DIR}/yaml"}},
|
47
|
+
{
|
48
|
+
name: "ActiveRecord (MySQL)",
|
49
|
+
adapter: :ActiveRecord,
|
50
|
+
options: {
|
51
|
+
table: 'activerecord',
|
52
|
+
connection: {
|
53
|
+
adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'),
|
54
|
+
username: mysql_username,
|
55
|
+
database: mysql_database1
|
56
|
+
}
|
57
|
+
}
|
58
|
+
},
|
59
|
+
{
|
60
|
+
name: "ActiveRecord (Postgres)",
|
61
|
+
adapter: :ActiveRecord,
|
62
|
+
options: {
|
63
|
+
table: 'activerecord',
|
64
|
+
connection: {
|
65
|
+
adapter: (defined?(JRUBY_VERSION) ? 'jdbcpostgresql' : 'postgresql'),
|
66
|
+
database: postgres_database1,
|
67
|
+
username: postgres_username
|
68
|
+
}
|
69
|
+
}
|
70
|
+
},
|
71
|
+
{
|
72
|
+
name: "ActiveRecord (Sqlite)",
|
73
|
+
adapter: :ActiveRecord,
|
74
|
+
options: {
|
75
|
+
table: 'activerecord',
|
76
|
+
connection: {
|
77
|
+
adapter: (defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3'),
|
78
|
+
database: "#{DIR}/activerecord_sqlite.db"
|
79
|
+
}
|
80
|
+
}
|
81
|
+
},
|
82
|
+
{
|
83
|
+
name: "ActiveSupportCache (Memory)",
|
84
|
+
adapter: :ActiveSupportCache,
|
85
|
+
options: {
|
86
|
+
backend: ::ActiveSupport::Cache::MemoryStore.new
|
87
|
+
}
|
88
|
+
},
|
89
|
+
{
|
90
|
+
name: "ActiveSupportCache (Redis)",
|
91
|
+
adapter: :ActiveSupportCache,
|
92
|
+
options: {
|
93
|
+
backend: ::ActiveSupport::Cache::RedisCacheStore.new
|
94
|
+
}
|
95
|
+
},
|
96
|
+
{
|
97
|
+
name: "ActiveSupportCache (Moneta Memory)",
|
98
|
+
adapter: :ActiveSupportCache,
|
99
|
+
options: {
|
100
|
+
backend: ::ActiveSupport::Cache::MonetaStore.new(store: Moneta.new(:Memory))
|
101
|
+
}
|
102
|
+
},
|
103
|
+
{
|
104
|
+
name: "ActiveSupportCache (Moneta Redis)",
|
105
|
+
adapter: :ActiveSupportCache,
|
106
|
+
options: {
|
107
|
+
backend: ::ActiveSupport::Cache::MonetaStore.new(store: Moneta.new(:Redis))
|
108
|
+
}
|
109
|
+
},
|
110
|
+
{name: "Cassandra"},
|
111
|
+
{name: "Client (Memory)", adapter: :Client},
|
112
|
+
{
|
113
|
+
name: "Couch",
|
114
|
+
options: {
|
115
|
+
backend: if defined?(JRUBY_VERSION)
|
116
|
+
require 'faraday/adapter/manticore'
|
117
|
+
::Faraday.new("http://127.0.0.1:5984/moneta") { |f| f.adapter :manticore }
|
118
|
+
end,
|
119
|
+
login: couch_login,
|
120
|
+
password: couch_password
|
121
|
+
},
|
122
|
+
clear_options: { compact: true, await_compact: true },
|
123
|
+
},
|
124
|
+
{
|
125
|
+
name: "DBM",
|
126
|
+
options: {file: "#{DIR}/dbm"}
|
127
|
+
},
|
128
|
+
{
|
129
|
+
name: "DataMapper",
|
130
|
+
options: {
|
131
|
+
setup: "mysql://#{mysql_username}:@localhost/#{mysql_database1}",
|
132
|
+
table: 'datamapper'
|
133
|
+
}
|
134
|
+
},
|
135
|
+
{
|
136
|
+
name: "Daybreak",
|
137
|
+
options: { file: "#{DIR}/daybreak" },
|
138
|
+
},
|
139
|
+
{
|
140
|
+
name: "File",
|
141
|
+
options: {
|
142
|
+
dir: "#{DIR}/file"
|
143
|
+
}
|
144
|
+
},
|
145
|
+
{name: "GDBM", options: {file: "#{DIR}/gdbm"}},
|
146
|
+
{name: "HBase"},
|
147
|
+
{name: "HashFile", options: { dir: "#{DIR}/hashfile" }},
|
148
|
+
{name: "KyotoCabinet", options: { file: "#{DIR}/kyotocabinet.kch" }},
|
149
|
+
{name: "LRUHash"},
|
150
|
+
{name: "LevelDB", options: { dir: "#{DIR}/leveldb" }},
|
151
|
+
{name: "LocalMemCache", options: { file: "#{DIR}/lmc" }},
|
152
|
+
{
|
153
|
+
name: "LMDB",
|
154
|
+
options: {
|
155
|
+
dir: "#{DIR}/lmdb",
|
156
|
+
writemap: true,
|
157
|
+
mapasync: true,
|
158
|
+
nometasync: true,
|
159
|
+
mapsize: 4096 * 3e2
|
160
|
+
}
|
161
|
+
},
|
162
|
+
{name: "MemcachedDalli"},
|
163
|
+
unless defined?(JRUBY_VERSION)
|
164
|
+
{name: "MemcachedNative"}
|
165
|
+
end,
|
166
|
+
{name: "Memory"},
|
167
|
+
{name: "Mongo"},
|
168
|
+
{name: "PStore", options: { file: "#{DIR}/pstore" }},
|
169
|
+
{name: "Redis"},
|
170
|
+
{
|
171
|
+
name: "RestClient (Memory)",
|
172
|
+
adapter: :RestClient,
|
173
|
+
options: {
|
174
|
+
url: 'http://127.0.0.1:8808/moneta',
|
175
|
+
backend: if defined?(JRUBY_VERSION)
|
176
|
+
require 'faraday/adapter/manticore'
|
177
|
+
::Faraday.new("http://127.0.0.1:8808/moneta") { |f| f.adapter :manticore }
|
178
|
+
end
|
179
|
+
}
|
180
|
+
},
|
181
|
+
{name: "Riak"},
|
182
|
+
{
|
183
|
+
name: "Sequel (MySQL)",
|
184
|
+
adapter: :Sequel,
|
185
|
+
options: {
|
186
|
+
table: 'sequel',
|
187
|
+
db: (defined?(JRUBY_VERSION) ?
|
188
|
+
"jdbc:mysql://localhost/#{mysql_database1}?user=#{mysql_username}" :
|
189
|
+
"mysql2://#{mysql_username}:@localhost/#{mysql_database1}")
|
190
|
+
}
|
191
|
+
},
|
192
|
+
{
|
193
|
+
name: "Sequel (Postgres)",
|
194
|
+
adapter: :Sequel,
|
195
|
+
options:
|
196
|
+
if defined?(JRUBY_VERSION)
|
197
|
+
{db: "jdbc:postgresql://localhost/#{postgres_database1}?user=#{postgres_username}"}
|
198
|
+
else
|
199
|
+
{
|
200
|
+
db: "postgres://localhost/#{postgres_database1}",
|
201
|
+
user: postgres_username
|
202
|
+
}
|
203
|
+
end.merge(table: 'sequel')
|
204
|
+
},
|
205
|
+
{
|
206
|
+
name: "Sequel (HStore)",
|
207
|
+
adapter: :Sequel,
|
208
|
+
options:
|
209
|
+
if defined?(JRUBY_VERSION)
|
210
|
+
{db: "jdbc:postgresql://localhost/#{postgres_database1}?user=#{postgres_username}"}
|
211
|
+
else
|
212
|
+
{
|
213
|
+
db: "postgres://localhost/#{postgres_database1}",
|
214
|
+
user: postgres_username
|
215
|
+
}
|
216
|
+
end.merge(table: 'sequel_hstore', hstore: 'row')
|
217
|
+
},
|
218
|
+
{
|
219
|
+
name: "Sequel (Sqlite)",
|
220
|
+
adapter: :Sequel,
|
221
|
+
options: {
|
222
|
+
table: 'sequel',
|
223
|
+
db: "#{defined?(JRUBY_VERSION) && 'jdbc:'}sqlite://#{DIR}/sequel"
|
224
|
+
}
|
225
|
+
},
|
226
|
+
{
|
227
|
+
name: "Sqlite (Memory)",
|
228
|
+
adapter: :Sqlite,
|
229
|
+
options: {
|
230
|
+
file: ':memory:'
|
231
|
+
}
|
232
|
+
},
|
233
|
+
{
|
234
|
+
name: "Sqlite (File)",
|
235
|
+
adapter: :Sqlite,
|
236
|
+
options: {
|
237
|
+
file: "#{DIR}/sqlite"
|
238
|
+
}
|
239
|
+
},
|
240
|
+
{name: "TDB", options: { file: "#{DIR}/tdb" }},
|
241
|
+
{name: "TokyoCabinet", options: { file: "#{DIR}/tokyocabinet" }},
|
242
|
+
{name: "TokyoTyrant", options: {port: 10431}},
|
243
|
+
].compact
|
71
244
|
|
72
245
|
CONFIGS = {
|
246
|
+
test: {
|
247
|
+
runs: 2,
|
248
|
+
keys: 10,
|
249
|
+
min_key_len: 1,
|
250
|
+
max_key_len: 32,
|
251
|
+
key_dist: :uniform,
|
252
|
+
min_val_len: 0,
|
253
|
+
max_val_len: 256,
|
254
|
+
val_dist: :uniform
|
255
|
+
},
|
73
256
|
uniform_small: {
|
74
257
|
runs: 3,
|
75
258
|
keys: 1000,
|
@@ -133,8 +316,6 @@ class MonetaBenchmarks
|
|
133
316
|
}
|
134
317
|
|
135
318
|
DICT = 'ABCDEFGHIJKLNOPQRSTUVWXYZabcdefghijklnopqrstuvwxyz123456789'.freeze
|
136
|
-
HEADER = "\n Minimum Maximum Total Mean Stddev Ops/s"
|
137
|
-
SEPARATOR = '=' * 77
|
138
319
|
|
139
320
|
module Rand
|
140
321
|
extend self
|
@@ -162,6 +343,14 @@ class MonetaBenchmarks
|
|
162
343
|
end
|
163
344
|
end
|
164
345
|
|
346
|
+
def header
|
347
|
+
(" " * @name_len) + " Minimum Maximum Total Mean Stddev Ops/s"
|
348
|
+
end
|
349
|
+
|
350
|
+
def separator
|
351
|
+
"=" * header.length
|
352
|
+
end
|
353
|
+
|
165
354
|
def parallel(&block)
|
166
355
|
if defined?(JRUBY_VERSION)
|
167
356
|
Thread.new(&block)
|
@@ -185,63 +374,67 @@ class MonetaBenchmarks
|
|
185
374
|
end
|
186
375
|
|
187
376
|
def start_servers
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
377
|
+
@moneta_server_handle =
|
378
|
+
parallel do
|
379
|
+
begin
|
380
|
+
Moneta::Server.new(Moneta.new(:Memory)).run
|
381
|
+
rescue => ex
|
382
|
+
puts "\e[31mFailed to start Moneta server - #{ex.message}\e[0m"
|
383
|
+
end
|
193
384
|
end
|
194
|
-
end
|
195
385
|
|
196
|
-
|
197
|
-
begin
|
198
|
-
require 'rack'
|
199
|
-
require 'webrick'
|
200
|
-
require 'rack/moneta_rest'
|
386
|
+
@restserver_handle = start_restserver(8808)
|
201
387
|
|
202
|
-
|
203
|
-
::WEBrick::HTTPServer.class_eval do
|
204
|
-
def access_log(config, req, res); end
|
205
|
-
end
|
206
|
-
::WEBrick::BasicLog.class_eval do
|
207
|
-
def log(level, data); end
|
208
|
-
end
|
388
|
+
@tokyotyrant_handle = spawn("ttserver -port 10431 -le -log #{DIR}/tokyotyrant.log #{DIR}/tokyotyrant.tch")
|
209
389
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
end,
|
214
|
-
environment: :none,
|
215
|
-
server: :webrick,
|
216
|
-
Port: 8808)
|
217
|
-
rescue Exception => ex
|
218
|
-
puts "\e[31mFailed to start Rack server - #{ex.message}\e[0m"
|
219
|
-
end
|
390
|
+
Signal.trap "INT" do
|
391
|
+
stop_servers
|
392
|
+
exit
|
220
393
|
end
|
221
394
|
|
222
395
|
sleep 1 # Wait for servers
|
223
396
|
end
|
224
397
|
|
398
|
+
def stop_servers
|
399
|
+
if @restserver_handle
|
400
|
+
stop_restserver(@restserver_handle)
|
401
|
+
@restserver_handle = nil
|
402
|
+
end
|
403
|
+
|
404
|
+
case @moneta_server_handle
|
405
|
+
when Thread
|
406
|
+
Thread.kill @moneta_server_handle
|
407
|
+
when Integer
|
408
|
+
Process.kill "TERM", @moneta_server_handle
|
409
|
+
Process.wait @moneta_server_handle
|
410
|
+
end
|
411
|
+
|
412
|
+
Process.kill "TERM", @tokyotyrant_handle
|
413
|
+
end
|
414
|
+
|
225
415
|
def test_stores
|
226
|
-
|
416
|
+
@stores.select! do |spec|
|
417
|
+
adapter = spec[:adapter] || spec[:name].to_sym
|
418
|
+
options = spec[:options] || {}
|
227
419
|
begin
|
228
|
-
if
|
420
|
+
if adapter == :DataMapper
|
229
421
|
begin
|
230
422
|
require 'dm-core'
|
231
423
|
DataMapper.setup(:default, adapter: :in_memory)
|
232
424
|
rescue LoadError => ex
|
233
425
|
puts "\e[31mFailed to load DataMapper - #{ex.message}\e[0m"
|
234
426
|
end
|
235
|
-
elsif
|
427
|
+
elsif adapter == :Riak
|
236
428
|
require 'riak'
|
237
429
|
Riak.disable_list_keys_warnings = true
|
238
430
|
end
|
239
431
|
|
240
|
-
cache = Moneta.new(
|
432
|
+
cache = Moneta.new(adapter, options.dup)
|
241
433
|
cache['test'] = 'test'
|
434
|
+
true
|
242
435
|
rescue Exception => ex
|
243
|
-
puts "\e[31m#{name} not benchmarked - #{ex.message}\e[0m"
|
244
|
-
|
436
|
+
puts "\e[31m#{spec[:name]} not benchmarked - #{ex.message}\e[0m"
|
437
|
+
false
|
245
438
|
ensure
|
246
439
|
(cache.close rescue nil) if cache
|
247
440
|
end
|
@@ -260,26 +453,26 @@ class MonetaBenchmarks
|
|
260
453
|
write_histogram("#{DIR}/key.histogram", key_lens)
|
261
454
|
write_histogram("#{DIR}/value.histogram", val_lens)
|
262
455
|
|
263
|
-
puts "\n\e[1m\e[34m#{
|
264
|
-
puts %{
|
265
|
-
puts 'Key Length
|
266
|
-
puts 'Value Length
|
456
|
+
puts "\n\e[1m\e[34m#{separator}\n\e[34mComputing keys and values...\n\e[34m#{separator}\e[0m"
|
457
|
+
puts " " * @name_len + %{ Minimum Maximum Total Mean Stddev}
|
458
|
+
puts 'Key Length'.ljust(@name_len) + ' % 8d % 8d % 8d % 8d % 8d' % [key_lens.min, key_lens.max, key_lens.sum, mean(key_lens), stddev(key_lens)]
|
459
|
+
puts 'Value Length'.ljust(@name_len) + ' % 8d % 8d % 8d % 8d % 8d' % [val_lens.min, val_lens.max, val_lens.sum, mean(val_lens), stddev(val_lens)]
|
267
460
|
end
|
268
461
|
|
269
462
|
def print_config
|
270
|
-
puts "\e[1m\e[36m#{
|
463
|
+
puts "\e[1m\e[36m#{separator}\n\e[36mConfig #{@config_name}\n\e[36m#{separator}\e[0m"
|
271
464
|
@config.each do |k,v|
|
272
465
|
puts '%-16s = %-10s' % [k,v]
|
273
466
|
end
|
274
467
|
end
|
275
468
|
|
276
469
|
def print_store_stats(name)
|
277
|
-
puts
|
470
|
+
puts "\n" + header
|
278
471
|
[:write, :read, :sum].each do |i|
|
279
472
|
ops = (1000 * @config[:runs] * @data.size) / @stats[name][i].sum
|
280
|
-
line =
|
473
|
+
line = "%-#{@name_len-1}.#{@name_len-1}s %-5s % 8d % 8d % 8d % 8d % 8d % 8d" %
|
281
474
|
[name, i, @stats[name][i].min, @stats[name][i].max, @stats[name][i].sum,
|
282
|
-
@stats[name][i]
|
475
|
+
mean(@stats[name][i]), stddev(@stats[name][i]), ops]
|
283
476
|
@summary << [-ops, line << "\n"] if i == :sum
|
284
477
|
puts line
|
285
478
|
end
|
@@ -293,10 +486,13 @@ class MonetaBenchmarks
|
|
293
486
|
end
|
294
487
|
end
|
295
488
|
|
296
|
-
def benchmark_store(
|
297
|
-
|
489
|
+
def benchmark_store(spec)
|
490
|
+
name = spec[:name]
|
491
|
+
adapter = spec[:adapter] || spec[:name].to_sym
|
492
|
+
options = spec[:options] || {}
|
493
|
+
puts "\n\e[1m\e[34m#{separator}\n\e[34m#{name}\n\e[34m#{separator}\e[0m"
|
298
494
|
|
299
|
-
store = Moneta.new(
|
495
|
+
store = Moneta.new(adapter, options.dup)
|
300
496
|
|
301
497
|
@stats[name] = {
|
302
498
|
write: [],
|
@@ -310,7 +506,7 @@ class MonetaBenchmarks
|
|
310
506
|
print "%s [%#{2 * @config[:runs]}s] " % [type, state]
|
311
507
|
|
312
508
|
@config[:runs].times do |run|
|
313
|
-
store.clear
|
509
|
+
store.clear(spec[:clear_options] || {})
|
314
510
|
|
315
511
|
@data.shuffle!
|
316
512
|
m1 = Benchmark.measure do
|
@@ -346,14 +542,14 @@ class MonetaBenchmarks
|
|
346
542
|
end
|
347
543
|
|
348
544
|
def run_benchmarks
|
349
|
-
|
350
|
-
benchmark_store(
|
545
|
+
@stores.each do |spec|
|
546
|
+
benchmark_store(spec)
|
351
547
|
sleep 1
|
352
548
|
end
|
353
549
|
end
|
354
550
|
|
355
551
|
def print_summary
|
356
|
-
puts "\n\e[1m\e[36m#{
|
552
|
+
puts "\n\e[1m\e[36m#{separator}\n\e[36mSummary #{@config_name}: #{@config[:runs]} runs, #{@data.size} keys\n\e[36m#{separator}\e[0m\n#{header}\n"
|
357
553
|
@summary.sort_by(&:first).each do |entry|
|
358
554
|
puts entry.last
|
359
555
|
end
|
@@ -366,6 +562,20 @@ class MonetaBenchmarks
|
|
366
562
|
exit
|
367
563
|
end
|
368
564
|
|
565
|
+
@size = @config_name.to_s.split('_').last.to_sym
|
566
|
+
@stores =
|
567
|
+
if ENV['MONETA_STORES']
|
568
|
+
store_names = ENV['MONETA_STORES'].split(/,\s*/)
|
569
|
+
STORES.select { |spec| store_names.any? { |name| name == spec[:name] } }
|
570
|
+
elsif ENV['MONETA_STORES_MATCHING']
|
571
|
+
r = Regexp.new(ENV['MONETA_STORES_MATCHING'])
|
572
|
+
STORES.select { |spec| spec[:name].match(r) }
|
573
|
+
else
|
574
|
+
STORES
|
575
|
+
end.select { |spec| !spec.key?(:sizes) || spec[:sizes].include?(@size) }
|
576
|
+
|
577
|
+
@name_len = (@stores.map { |spec| spec[:name] }.map(&:length) + ["Value Length".length]).max + 2
|
578
|
+
|
369
579
|
# Disable jruby stdout pollution by memcached
|
370
580
|
if defined?(JRUBY_VERSION)
|
371
581
|
require 'java'
|
@@ -387,6 +597,7 @@ class MonetaBenchmarks
|
|
387
597
|
generate_data
|
388
598
|
run_benchmarks
|
389
599
|
print_summary
|
600
|
+
stop_servers
|
390
601
|
FileUtils.rm_rf(DIR)
|
391
602
|
end
|
392
603
|
end
|
data/script/contributors
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
-
#!/bin/
|
2
|
-
git log --format='%aN <%aE>' |\
|
3
|
-
sed -e 's/hiddenbek/Scott Wadden/g' |\
|
4
|
-
sed -e 's/Asmod4n/Hendrik Beskow/' |\
|
5
|
-
grep -v 'hannes.georg@xing.com\|spotapov\|yehuda-katzs-mac\|wycats ' |\
|
6
|
-
sort -u | sort > CONTRIBUTORS
|
1
|
+
#!/usr/bin/env ruby
|
7
2
|
|
3
|
+
contributors = `git log --format='%aN <%aE>'`
|
4
|
+
.gsub(/hiddenbek/, 'Scott Wadden')
|
5
|
+
.gsub(/Asmod4n/, 'Hendrik Beskow')
|
6
|
+
.lines
|
7
|
+
.uniq
|
8
|
+
.reject { |line| line.match? /asppsa@gmail.com|hannes.georg@xing.com|spotapov|yehuda-katzs-mac|wycats / }
|
9
|
+
.sort { |str1, str2| str1.casecmp(str2) }
|
10
|
+
|
11
|
+
file = File.open('CONTRIBUTORS', 'w')
|
12
|
+
file << contributors.join
|