moneta 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rspec +4 -0
- data/.travis.yml +83 -32
- data/.yardopts +6 -1
- data/CHANGES +30 -0
- data/CONTRIBUTORS +4 -0
- data/Gemfile +28 -36
- data/LICENSE +1 -1
- data/README.md +136 -67
- data/SPEC.md +70 -0
- data/feature_matrix.yaml +235 -0
- data/lib/active_support/cache/moneta_store.rb +102 -6
- data/lib/moneta.rb +9 -2
- data/lib/moneta/adapters/activerecord.rb +258 -98
- data/lib/moneta/adapters/activesupportcache.rb +133 -0
- data/lib/moneta/adapters/cassandra.rb +290 -44
- data/lib/moneta/adapters/client.rb +11 -2
- data/lib/moneta/adapters/couch.rb +179 -25
- data/lib/moneta/adapters/datamapper.rb +1 -0
- data/lib/moneta/adapters/daybreak.rb +21 -4
- data/lib/moneta/adapters/dbm.rb +7 -7
- data/lib/moneta/adapters/file.rb +11 -1
- data/lib/moneta/adapters/gdbm.rb +7 -7
- data/lib/moneta/adapters/kyotocabinet.rb +66 -1
- data/lib/moneta/adapters/leveldb.rb +27 -1
- data/lib/moneta/adapters/lmdb.rb +29 -1
- data/lib/moneta/adapters/lruhash.rb +30 -0
- data/lib/moneta/adapters/memcached/dalli.rb +50 -5
- data/lib/moneta/adapters/memcached/native.rb +11 -4
- data/lib/moneta/adapters/memory.rb +2 -0
- data/lib/moneta/adapters/mongo/base.rb +32 -7
- data/lib/moneta/adapters/mongo/moped.rb +59 -2
- data/lib/moneta/adapters/mongo/official.rb +40 -0
- data/lib/moneta/adapters/pstore.rb +56 -8
- data/lib/moneta/adapters/redis.rb +79 -19
- data/lib/moneta/adapters/sdbm.rb +7 -7
- data/lib/moneta/adapters/sequel.rb +440 -39
- data/lib/moneta/adapters/sqlite.rb +74 -10
- data/lib/moneta/adapters/tdb.rb +16 -1
- data/lib/moneta/adapters/tokyocabinet.rb +7 -1
- data/lib/moneta/adapters/tokyotyrant.rb +22 -0
- data/lib/moneta/cache.rb +11 -1
- data/lib/moneta/expires.rb +110 -8
- data/lib/moneta/lock.rb +21 -2
- data/lib/moneta/mixins.rb +279 -3
- data/lib/moneta/pool.rb +15 -6
- data/lib/moneta/proxy.rb +46 -2
- data/lib/moneta/server.rb +5 -1
- data/lib/moneta/shared.rb +27 -11
- data/lib/moneta/stack.rb +1 -1
- data/lib/moneta/synchronize.rb +2 -8
- data/lib/moneta/transformer.rb +152 -2
- data/lib/moneta/transformer/config.rb +2 -0
- data/lib/moneta/transformer/helper.rb +2 -2
- data/lib/moneta/version.rb +1 -1
- data/lib/moneta/weak_each_key.rb +74 -0
- data/lib/moneta/wrapper.rb +25 -0
- data/moneta.gemspec +2 -2
- data/script/benchmarks +174 -62
- data/script/parallel-tests +58 -83
- data/script/start-hbase +46 -0
- data/script/start-services +9 -2
- data/script/update-feature-matrix +148 -0
- data/spec/active_support/cache_moneta_store_spec.rb +132 -109
- data/spec/features/concurrent_create.rb +21 -0
- data/spec/features/concurrent_increment.rb +32 -0
- data/spec/features/create.rb +25 -0
- data/spec/features/create_expires.rb +19 -0
- data/spec/features/default_expires.rb +15 -0
- data/spec/features/each_key.rb +119 -0
- data/spec/features/expires.rb +291 -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 +391 -74
- data/spec/moneta/adapters/activerecord/adapter_activerecord_existing_connection_spec.rb +59 -0
- data/spec/moneta/adapters/activerecord/adapter_activerecord_spec.rb +118 -0
- data/spec/moneta/adapters/activerecord/standard_activerecord_spec.rb +18 -0
- data/spec/moneta/adapters/activerecord/standard_activerecord_with_expires_spec.rb +24 -0
- data/spec/moneta/adapters/activesupportcache/adapter_activesupportcache_spec.rb +51 -0
- data/spec/moneta/adapters/activesupportcache/adapter_activesupportcache_with_default_expires_spec.rb +51 -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/standard_client_tcp_spec.rb +23 -0
- data/spec/moneta/adapters/client/standard_client_unix_spec.rb +12 -0
- data/spec/moneta/adapters/cookie/adapter_cookie_spec.rb +7 -0
- data/spec/moneta/adapters/couch/adapter_couch_spec.rb +7 -0
- data/spec/moneta/adapters/couch/standard_couch_spec.rb +9 -0
- data/spec/moneta/adapters/couch/standard_couch_with_expires_spec.rb +13 -0
- data/spec/moneta/adapters/datamapper/adapter_datamapper_spec.rb +43 -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/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} +3 -25
- 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 +15 -0
- data/spec/moneta/adapters/memcached/dalli/adapter_memcached_dalli_with_default_expires_spec.rb +15 -0
- data/spec/moneta/adapters/memcached/dalli/standard_memcached_dalli_spec.rb +11 -0
- data/spec/moneta/adapters/memcached/helper.rb +20 -0
- data/spec/moneta/adapters/memcached/native/adapter_memcached_native_spec.rb +15 -0
- data/spec/moneta/adapters/memcached/native/adapter_memcached_native_with_default_expires_spec.rb +15 -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/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 +4 -0
- data/spec/moneta/adapters/memory/standard_memory_with_snappy_compress_spec.rb +9 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_moped_spec.rb +25 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_moped_with_default_expires_spec.rb +12 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_official_spec.rb +25 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_official_with_default_expires_spec.rb +12 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_spec.rb +11 -0
- data/spec/moneta/adapters/mongo/adapter_mongo_with_default_expires_spec.rb +12 -0
- data/spec/moneta/adapters/mongo/standard_mongo_moped_spec.rb +7 -0
- data/spec/moneta/adapters/mongo/standard_mongo_official_spec.rb +7 -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 +10 -0
- data/spec/moneta/adapters/redis/adapter_redis_with_default_expires_spec.rb +10 -0
- data/spec/moneta/adapters/redis/standard_redis_spec.rb +7 -0
- data/spec/moneta/adapters/restclient/adapter_restclient_spec.rb +11 -0
- data/spec/moneta/adapters/restclient/standard_restclient_spec.rb +10 -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 +10 -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 +181 -0
- data/spec/moneta/adapters/sequel/standard_sequel_spec.rb +14 -0
- data/spec/moneta/adapters/sequel/standard_sequel_with_expires_spec.rb +19 -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 +7 -0
- data/spec/moneta/adapters/tokyotyrant/standard_tokyotyrant_spec.rb +4 -0
- data/spec/moneta/adapters/tokyotyrant/standard_tokyotyrant_with_expires_spec.rb +8 -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 +0 -1
- 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/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/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 +12 -0
- data/spec/moneta/proxies/proxy/proxy_expires_memory_spec.rb +16 -0
- data/spec/moneta/proxies/proxy/proxy_redis_spec.rb +13 -0
- data/spec/moneta/proxies/shared/shared_tcp_spec.rb +49 -0
- data/spec/moneta/proxies/shared/shared_unix_spec.rb +48 -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 +23 -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 +15 -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_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 +24 -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/quality_spec.rb +1 -1
- 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 +415 -355
- data/script/generate-specs +0 -2696
- 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
@@ -35,14 +35,14 @@ module Moneta
|
|
35
35
|
|
36
36
|
def bzip2(value)
|
37
37
|
io = ::StringIO.new
|
38
|
-
bz = ::RBzip2::Compressor.new(io)
|
38
|
+
bz = ::RBzip2.default_adapter::Compressor.new(io)
|
39
39
|
bz.write(value)
|
40
40
|
bz.close
|
41
41
|
io.string
|
42
42
|
end
|
43
43
|
|
44
44
|
def bunzip2(value)
|
45
|
-
::RBzip2::Decompressor.new(::StringIO.new(value)).read
|
45
|
+
::RBzip2.default_adapter::Decompressor.new(::StringIO.new(value)).read
|
46
46
|
end
|
47
47
|
|
48
48
|
autoload :BSON, 'moneta/transformer/helper/bson'
|
data/lib/moneta/version.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module Moneta
|
4
|
+
# Adds weak key enumeration support to the underlying store
|
5
|
+
#
|
6
|
+
# @note This class wraps methods that store and retrieve entries in order to
|
7
|
+
# track which keys are in the store, and uses this list when doing key
|
8
|
+
# traversal. This means that {#each_key each_key} will only yield keys
|
9
|
+
# which have been accessed previously via the present store object. This
|
10
|
+
# wrapper is therefore best suited to adapters which are not persistent, and
|
11
|
+
# which cannot be shared.
|
12
|
+
#
|
13
|
+
# @api public
|
14
|
+
class WeakEachKey < Wrapper
|
15
|
+
supports :each_key
|
16
|
+
|
17
|
+
# @param [Moneta store] adapter The underlying store
|
18
|
+
# @param [Hash] options
|
19
|
+
def initialize(adapter, options = {})
|
20
|
+
raise 'Store already supports feature :each_key' if adapter.supports?(:each_key)
|
21
|
+
@all_keys = Set.new
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
# (see Proxy#each_key)
|
26
|
+
def each_key
|
27
|
+
return enum_for(:each_key) { all_keys.size } unless block_given?
|
28
|
+
all_keys.each { |key| yield key }
|
29
|
+
self
|
30
|
+
end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def wrap(name, *args)
|
35
|
+
case name
|
36
|
+
when :create, :store, :increment, :create
|
37
|
+
each_key_save(args[0])
|
38
|
+
yield
|
39
|
+
when :key?
|
40
|
+
if found = yield
|
41
|
+
each_key_save(args[0])
|
42
|
+
else
|
43
|
+
all_keys.delete(args[0])
|
44
|
+
end
|
45
|
+
found
|
46
|
+
when :load
|
47
|
+
key?(*args)
|
48
|
+
yield
|
49
|
+
when :delete
|
50
|
+
all_keys.delete(args[0])
|
51
|
+
yield
|
52
|
+
when :clear, :close
|
53
|
+
all_keys.clear
|
54
|
+
yield
|
55
|
+
when :values_at, :fetch_values, :slice
|
56
|
+
args[0].each { |key| key?(key) }
|
57
|
+
yield
|
58
|
+
when :merge!
|
59
|
+
args[0].each { |key, _| each_key_save(key) }
|
60
|
+
yield
|
61
|
+
else
|
62
|
+
yield
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def all_keys
|
67
|
+
@all_keys
|
68
|
+
end
|
69
|
+
|
70
|
+
def each_key_save(key)
|
71
|
+
@all_keys = Set.new(@all_keys).add(key)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/moneta/wrapper.rb
CHANGED
@@ -46,5 +46,30 @@ module Moneta
|
|
46
46
|
def features
|
47
47
|
wrap(:features) { super }
|
48
48
|
end
|
49
|
+
|
50
|
+
# (see Proxy#each_key)
|
51
|
+
def each_key(&block)
|
52
|
+
wrap(:each_key) { super }
|
53
|
+
end
|
54
|
+
|
55
|
+
# (see Proxy#values_at)
|
56
|
+
def values_at(*keys, **options)
|
57
|
+
wrap(:values_at, keys, options) { super }
|
58
|
+
end
|
59
|
+
|
60
|
+
# (see Proxy#fetch_values)
|
61
|
+
def fetch_values(*keys, **options, &defaults)
|
62
|
+
wrap(:fetch_values, keys, options, defaults) { super }
|
63
|
+
end
|
64
|
+
|
65
|
+
# (see Proxy#slice)
|
66
|
+
def slice(*keys, **options)
|
67
|
+
wrap(:slice, keys, options) { super }
|
68
|
+
end
|
69
|
+
|
70
|
+
# (see Proxy#merge!)
|
71
|
+
def merge!(pairs, options = {})
|
72
|
+
wrap(:merge!, pairs, options) { super }
|
73
|
+
end
|
49
74
|
end
|
50
75
|
end
|
data/moneta.gemspec
CHANGED
@@ -13,9 +13,9 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
15
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
-
s.homepage = 'http://github.com/
|
16
|
+
s.homepage = 'http://github.com/moneta-rb/moneta'
|
17
17
|
s.licenses = %w(MIT)
|
18
18
|
s.require_paths = %w(lib)
|
19
19
|
s.summary = %{A unified interface to key/value stores, including Redis, Memcached, TokyoCabinet, ActiveRecord and many more}
|
20
|
-
s.required_ruby_version = '>=
|
20
|
+
s.required_ruby_version = '>= 2.2.2'
|
21
21
|
end
|
data/script/benchmarks
CHANGED
@@ -4,6 +4,7 @@ $: << File.join(File.dirname(__FILE__), '..', 'lib')
|
|
4
4
|
require 'benchmark'
|
5
5
|
require 'moneta'
|
6
6
|
require 'fileutils'
|
7
|
+
require 'active_support'
|
7
8
|
|
8
9
|
class String
|
9
10
|
def random(n)
|
@@ -11,63 +12,156 @@ class String
|
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def mean
|
20
|
-
sum / size
|
21
|
-
end
|
15
|
+
def mean arr
|
16
|
+
arr.sum / arr.length
|
17
|
+
end
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
19
|
+
def stddev arr
|
20
|
+
m = mean(arr)
|
21
|
+
Math.sqrt(mean(arr.map {|s| (s - m) ** 2 }))
|
27
22
|
end
|
28
23
|
|
29
24
|
class MonetaBenchmarks
|
30
25
|
DIR = __FILE__ + '.tmp'
|
31
26
|
|
32
|
-
|
27
|
+
mysql_username = ENV['MONETA_MYSQL_USERNAME'] || 'root'
|
28
|
+
mysql_password = ENV['MONETA_MYSQL_PASSWORD']
|
29
|
+
mysql_database1 = ENV['MONETA_MYSQL_DATABSASE1'] || 'moneta'
|
30
|
+
mysql_database2 = ENV['MONETA_MYSQL_DATABSASE2'] || 'moneta2'
|
31
|
+
|
32
|
+
postgres_username = ENV['MONETA_POSTGRES_USERNAME'] || 'postgres'
|
33
|
+
postgres_database1 = ENV['MONETA_POSTGRES_DATABSASE1'] || 'moneta1'
|
34
|
+
postgres_database2 = ENV['MONETA_POSTGRES_DATABSASE1'] || 'moneta2'
|
35
|
+
|
36
|
+
STORES = [
|
33
37
|
# SDBM accepts only very short key/value pairs (1k for both)
|
34
|
-
|
38
|
+
{name: "SDBM", sizes: [:small], options: {file: "#{DIR}/sdbm"}},
|
35
39
|
# 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
|
-
|
40
|
+
#{name: "YAML", options: {file: "#{DIR}/yaml"}},
|
41
|
+
{
|
42
|
+
name: "ActiveRecord (MySQL)",
|
43
|
+
adapter: :ActiveRecord,
|
44
|
+
options: {
|
45
|
+
table: 'activerecord',
|
46
|
+
connection: {
|
47
|
+
adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'),
|
48
|
+
username: mysql_username,
|
49
|
+
database: mysql_database1
|
50
|
+
}
|
51
|
+
}
|
52
|
+
},
|
53
|
+
{
|
54
|
+
name: "ActiveRecord (Postgres)",
|
55
|
+
adapter: :ActiveRecord,
|
56
|
+
options: {
|
57
|
+
table: 'activerecord',
|
58
|
+
connection: {
|
59
|
+
adapter: (defined?(JRUBY_VERSION) ? 'jdbcpostgresql' : 'postgresql'),
|
60
|
+
database: postgres_database1,
|
61
|
+
username: postgres_username
|
62
|
+
}
|
63
|
+
}
|
64
|
+
},
|
65
|
+
{
|
66
|
+
name: "ActiveSupportCache (Memory)",
|
67
|
+
adapter: :ActiveSupportCache,
|
68
|
+
options: {
|
69
|
+
backend: ::ActiveSupport::Cache::MemoryStore.new
|
70
|
+
}
|
71
|
+
},
|
72
|
+
{
|
73
|
+
name: "ActiveSupportCache (Redis)",
|
74
|
+
adapter: :ActiveSupportCache,
|
75
|
+
options: {
|
76
|
+
backend: ::ActiveSupport::Cache::RedisCacheStore.new
|
77
|
+
}
|
78
|
+
},
|
79
|
+
{name: "Cassandra"},
|
80
|
+
{name: "Client (Memory)", adapter: :Client},
|
81
|
+
{name: "Couch"},
|
82
|
+
{
|
83
|
+
name: "DBM",
|
84
|
+
options: {file: "#{DIR}/dbm"}
|
85
|
+
},
|
86
|
+
{
|
87
|
+
name: "DataMapper",
|
88
|
+
options: {
|
89
|
+
setup: "mysql://#{mysql_username}:@localhost/#{mysql_database1}",
|
90
|
+
table: 'datamapper'
|
91
|
+
}
|
92
|
+
},
|
93
|
+
{
|
94
|
+
name: "Daybreak",
|
95
|
+
options: { file: "#{DIR}/daybreak" },
|
96
|
+
},
|
97
|
+
{
|
98
|
+
name: "File",
|
99
|
+
options: {
|
100
|
+
dir: "#{DIR}/file"
|
101
|
+
}
|
102
|
+
},
|
103
|
+
{name: "GDBM", options: {file: "#{DIR}/gdbm"}},
|
104
|
+
{name: "HBase"},
|
105
|
+
{name: "HashFile", options: { dir: "#{DIR}/hashfile" }},
|
106
|
+
{name: "KyotoCabinet", options: { file: "#{DIR}/kyotocabinet.kch" }},
|
107
|
+
{name: "LRUHash"},
|
108
|
+
{name: "LevelDB", options: { dir: "#{DIR}/leveldb" }},
|
109
|
+
{name: "LocalMemCache", options: { file: "#{DIR}/lmc" }},
|
110
|
+
{
|
111
|
+
name: "LMDB",
|
112
|
+
options: {
|
113
|
+
dir: "#{DIR}/lmdb",
|
114
|
+
writemap: true,
|
115
|
+
mapasync: true,
|
116
|
+
nometasync: true,
|
117
|
+
mapsize: 4096 * 3e2
|
118
|
+
}
|
119
|
+
},
|
120
|
+
{name: "MemcachedDalli"},
|
121
|
+
unless defined?(JRUBY_VERSION)
|
122
|
+
{name: "MemcachedNative"}
|
123
|
+
end,
|
124
|
+
{name: "Memory"},
|
125
|
+
{name: "MongoMoped"},
|
126
|
+
{name: "MongoOfficial"},
|
127
|
+
{name: "PStore", options: { file: "#{DIR}/pstore" }},
|
128
|
+
{name: "Redis"},
|
129
|
+
{name: "RestClient", options: { url: 'http://localhost:8808/' }},
|
130
|
+
{name: "Riak"},
|
131
|
+
{
|
132
|
+
name: "Sequel (MySQL)",
|
133
|
+
adapter: :Sequel,
|
134
|
+
options: {
|
135
|
+
table: 'sequel',
|
136
|
+
db: (defined?(JRUBY_VERSION) ?
|
137
|
+
"jdbc:mysql://localhost/#{mysql_database1}?user=#{mysql_username}" :
|
138
|
+
"mysql2://#{mysql_username}:@localhost/#{mysql_database1}")
|
139
|
+
}
|
140
|
+
},
|
141
|
+
{
|
142
|
+
name: "Sequel (Postgres)",
|
143
|
+
adapter: :Sequel,
|
144
|
+
options:
|
145
|
+
if defined?(JRUBY_VERSION)
|
146
|
+
{db: "jdbc:postgresql://localhost/#{postgres_database1}?user=#{postgres_username}"}
|
147
|
+
else
|
148
|
+
{
|
149
|
+
db: "postgres://localhost/#{postgres_database1}",
|
150
|
+
user: postgres_username
|
151
|
+
}
|
152
|
+
end.merge(table: 'sequel')
|
153
|
+
},
|
154
|
+
{
|
155
|
+
name: "Sqlite (Memory)",
|
156
|
+
adapter: :Sqlite,
|
157
|
+
options: {
|
158
|
+
file: ':memory:'
|
159
|
+
}
|
160
|
+
},
|
161
|
+
{name: "TDB", options: { file: "#{DIR}/tdb" }},
|
162
|
+
{name: "TokyoCabinet", options: { file: "#{DIR}/tokyocabinet" }},
|
163
|
+
{name: "TokyoTyrant"},
|
164
|
+
].compact
|
71
165
|
|
72
166
|
CONFIGS = {
|
73
167
|
uniform_small: {
|
@@ -223,25 +317,28 @@ class MonetaBenchmarks
|
|
223
317
|
end
|
224
318
|
|
225
319
|
def test_stores
|
226
|
-
|
320
|
+
@stores.select! do |spec|
|
321
|
+
adapter = spec[:adapter] || spec[:name].to_sym
|
322
|
+
options = spec[:options] || {}
|
227
323
|
begin
|
228
|
-
if
|
324
|
+
if adapter == :DataMapper
|
229
325
|
begin
|
230
326
|
require 'dm-core'
|
231
327
|
DataMapper.setup(:default, adapter: :in_memory)
|
232
328
|
rescue LoadError => ex
|
233
329
|
puts "\e[31mFailed to load DataMapper - #{ex.message}\e[0m"
|
234
330
|
end
|
235
|
-
elsif
|
331
|
+
elsif adapter == :Riak
|
236
332
|
require 'riak'
|
237
333
|
Riak.disable_list_keys_warnings = true
|
238
334
|
end
|
239
335
|
|
240
|
-
cache = Moneta.new(
|
336
|
+
cache = Moneta.new(adapter, options.dup)
|
241
337
|
cache['test'] = 'test'
|
338
|
+
true
|
242
339
|
rescue Exception => ex
|
243
|
-
puts "\e[31m#{name} not benchmarked - #{ex.message}\e[0m"
|
244
|
-
|
340
|
+
puts "\e[31m#{spec[:name]} not benchmarked - #{ex.message}\e[0m"
|
341
|
+
false
|
245
342
|
ensure
|
246
343
|
(cache.close rescue nil) if cache
|
247
344
|
end
|
@@ -262,8 +359,8 @@ class MonetaBenchmarks
|
|
262
359
|
|
263
360
|
puts "\n\e[1m\e[34m#{SEPARATOR}\n\e[34mComputing keys and values...\n\e[34m#{SEPARATOR}\e[0m"
|
264
361
|
puts %{ Minimum Maximum Total Mean Stddev}
|
265
|
-
puts 'Key Length % 8d % 8d % 8d % 8d % 8d' % [key_lens.min, key_lens.max, key_lens.sum, key_lens
|
266
|
-
puts 'Value Length % 8d % 8d % 8d % 8d % 8d' % [val_lens.min, val_lens.max, val_lens.sum, val_lens
|
362
|
+
puts 'Key Length % 8d % 8d % 8d % 8d % 8d' % [key_lens.min, key_lens.max, key_lens.sum, mean(key_lens), stddev(key_lens)]
|
363
|
+
puts 'Value Length % 8d % 8d % 8d % 8d % 8d' % [val_lens.min, val_lens.max, val_lens.sum, mean(val_lens), stddev(val_lens)]
|
267
364
|
end
|
268
365
|
|
269
366
|
def print_config
|
@@ -279,7 +376,7 @@ class MonetaBenchmarks
|
|
279
376
|
ops = (1000 * @config[:runs] * @data.size) / @stats[name][i].sum
|
280
377
|
line = '%-17.17s %-5s % 8d % 8d % 8d % 8d % 8d % 8d' %
|
281
378
|
[name, i, @stats[name][i].min, @stats[name][i].max, @stats[name][i].sum,
|
282
|
-
@stats[name][i]
|
379
|
+
mean(@stats[name][i]), mean(@stats[name][i]), ops]
|
283
380
|
@summary << [-ops, line << "\n"] if i == :sum
|
284
381
|
puts line
|
285
382
|
end
|
@@ -293,10 +390,13 @@ class MonetaBenchmarks
|
|
293
390
|
end
|
294
391
|
end
|
295
392
|
|
296
|
-
def benchmark_store(
|
393
|
+
def benchmark_store(spec)
|
394
|
+
name = spec[:name]
|
395
|
+
adapter = spec[:adapter] || spec[:name].to_sym
|
396
|
+
options = spec[:options] || {}
|
297
397
|
puts "\n\e[1m\e[34m#{SEPARATOR}\n\e[34m#{name}\n\e[34m#{SEPARATOR}\e[0m"
|
298
398
|
|
299
|
-
store = Moneta.new(
|
399
|
+
store = Moneta.new(adapter, options.dup)
|
300
400
|
|
301
401
|
@stats[name] = {
|
302
402
|
write: [],
|
@@ -346,8 +446,8 @@ class MonetaBenchmarks
|
|
346
446
|
end
|
347
447
|
|
348
448
|
def run_benchmarks
|
349
|
-
|
350
|
-
benchmark_store(
|
449
|
+
@stores.each do |spec|
|
450
|
+
benchmark_store(spec)
|
351
451
|
sleep 1
|
352
452
|
end
|
353
453
|
end
|
@@ -366,6 +466,18 @@ class MonetaBenchmarks
|
|
366
466
|
exit
|
367
467
|
end
|
368
468
|
|
469
|
+
@size = @config_name.to_s.split('_').last.to_sym
|
470
|
+
@stores =
|
471
|
+
if ENV['MONETA_STORES']
|
472
|
+
store_names = ENV['MONETA_STORES'].split(/,\s*/)
|
473
|
+
STORES.select { |spec| store_names.any? { |name| name == spec[:name] } }
|
474
|
+
elsif ENV['MONETA_STORES_MATCHING']
|
475
|
+
r = Regexp.new(ENV['MONETA_STORES_MATCHING'])
|
476
|
+
STORES.select { |spec| spec[:name].match(r) }
|
477
|
+
else
|
478
|
+
STORES
|
479
|
+
end.select { |spec| !spec.key?(:sizes) || spec[:sizes].include?(@size) }
|
480
|
+
|
369
481
|
# Disable jruby stdout pollution by memcached
|
370
482
|
if defined?(JRUBY_VERSION)
|
371
483
|
require 'java'
|