moneta 0.7.6 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +15 -0
- data/README.md +160 -50
- data/Rakefile +11 -2
- data/SPEC.md +7 -2
- data/lib/moneta.rb +7 -1
- data/lib/moneta/adapters/activerecord.rb +27 -3
- data/lib/moneta/adapters/cassandra.rb +1 -1
- data/lib/moneta/adapters/client.rb +8 -2
- data/lib/moneta/adapters/cookie.rb +1 -1
- data/lib/moneta/adapters/couch.rb +2 -1
- data/lib/moneta/adapters/datamapper.rb +16 -0
- data/lib/moneta/adapters/daybreak.rb +19 -1
- data/lib/moneta/adapters/file.rb +12 -0
- data/lib/moneta/adapters/hbase.rb +1 -2
- data/lib/moneta/adapters/lruhash.rb +4 -1
- data/lib/moneta/adapters/memcached.rb +7 -3
- data/lib/moneta/adapters/memcached/dalli.rb +8 -2
- data/lib/moneta/adapters/memcached/native.rb +10 -3
- data/lib/moneta/adapters/memory.rb +1 -0
- data/lib/moneta/adapters/mongo.rb +32 -5
- data/lib/moneta/adapters/pstore.rb +13 -2
- data/lib/moneta/adapters/redis.rb +19 -0
- data/lib/moneta/adapters/restclient.rb +1 -1
- data/lib/moneta/adapters/sequel.rb +20 -6
- data/lib/moneta/adapters/sqlite.rb +13 -1
- data/lib/moneta/adapters/tokyocabinet.rb +5 -0
- data/lib/moneta/cache.rb +10 -0
- data/lib/moneta/expires.rb +19 -22
- data/lib/moneta/lock.rb +2 -2
- data/lib/moneta/mixins.rb +33 -11
- data/lib/moneta/optionmerger.rb +1 -1
- data/lib/moneta/proxy.rb +13 -8
- data/lib/moneta/server.rb +13 -6
- data/lib/moneta/shared.rb +6 -10
- data/lib/moneta/synchronize.rb +125 -0
- data/lib/moneta/transformer.rb +50 -42
- data/lib/moneta/transformer/config.rb +34 -32
- data/lib/moneta/utils.rb +20 -0
- data/lib/moneta/version.rb +1 -1
- data/lib/moneta/weak.rb +17 -0
- data/lib/moneta/wrapper.rb +5 -0
- data/lib/rack/moneta_cookies.rb +2 -2
- data/lib/rack/moneta_store.rb +4 -4
- data/script/benchmarks +3 -9
- data/script/generate-specs +278 -41
- data/script/install-bundle +2 -2
- data/spec/moneta/adapter_activerecord_spec.rb +1 -0
- data/spec/moneta/adapter_cassandra_spec.rb +1 -0
- data/spec/moneta/adapter_cassandra_with_default_expires_spec.rb +1 -0
- data/spec/moneta/adapter_client_spec.rb +1 -0
- data/spec/moneta/adapter_cookie_spec.rb +1 -0
- data/spec/moneta/adapter_couch_spec.rb +1 -0
- data/spec/moneta/adapter_datamapper_spec.rb +1 -0
- data/spec/moneta/adapter_daybreak_spec.rb +1 -0
- data/spec/moneta/adapter_dbm_spec.rb +1 -0
- data/spec/moneta/adapter_file_spec.rb +1 -0
- data/spec/moneta/adapter_fog_spec.rb +1 -0
- data/spec/moneta/adapter_gdbm_spec.rb +1 -1
- data/spec/moneta/adapter_hbase_spec.rb +1 -0
- data/spec/moneta/adapter_leveldb_spec.rb +1 -0
- data/spec/moneta/adapter_localmemcache_spec.rb +1 -0
- data/spec/moneta/adapter_lruhash_spec.rb +1 -0
- data/spec/moneta/adapter_memcached_dalli_spec.rb +2 -0
- data/spec/moneta/adapter_memcached_dalli_with_default_expires_spec.rb +2 -0
- data/spec/moneta/adapter_memcached_native_spec.rb +2 -0
- data/spec/moneta/adapter_memcached_native_with_default_expires_spec.rb +2 -0
- data/spec/moneta/adapter_memcached_spec.rb +2 -0
- data/spec/moneta/adapter_memcached_with_default_expires_spec.rb +2 -0
- data/spec/moneta/adapter_memory_spec.rb +1 -0
- data/spec/moneta/adapter_mongo_spec.rb +2 -0
- data/spec/moneta/adapter_mongo_with_default_expires_spec.rb +2 -0
- data/spec/moneta/adapter_pstore_spec.rb +1 -0
- data/spec/moneta/adapter_redis_spec.rb +2 -0
- data/spec/moneta/adapter_redis_with_default_expires_spec.rb +2 -0
- data/spec/moneta/adapter_restclient_spec.rb +1 -0
- data/spec/moneta/adapter_riak_spec.rb +1 -0
- data/spec/moneta/adapter_sdbm_spec.rb +1 -0
- data/spec/moneta/adapter_sequel_spec.rb +1 -0
- data/spec/moneta/adapter_sqlite_spec.rb +1 -0
- data/spec/moneta/adapter_tdb_spec.rb +1 -0
- data/spec/moneta/adapter_tokyocabinet_bdb_spec.rb +1 -0
- data/spec/moneta/adapter_tokyocabinet_hdb_spec.rb +1 -0
- data/spec/moneta/adapter_yaml_spec.rb +1 -0
- data/spec/moneta/cache_file_memory_spec.rb +1 -0
- data/spec/moneta/cache_memory_null_spec.rb +1 -0
- data/spec/moneta/expires_file_spec.rb +3 -1
- data/spec/moneta/expires_memory_spec.rb +2 -0
- data/spec/moneta/expires_memory_with_default_expires_spec.rb +2 -0
- data/spec/moneta/lock_spec.rb +1 -0
- data/spec/moneta/mutex_spec.rb +71 -0
- data/spec/moneta/null_adapter_spec.rb +1 -0
- data/spec/moneta/optionmerger_spec.rb +5 -7
- data/spec/moneta/pool_spec.rb +1 -0
- data/spec/moneta/proxy_expires_memory_spec.rb +2 -0
- data/spec/moneta/proxy_redis_spec.rb +2 -0
- data/spec/moneta/semaphore_spec.rb +84 -0
- data/spec/moneta/{shared_spec.rb → shared_tcp_spec.rb} +4 -3
- data/spec/moneta/shared_unix_spec.rb +37 -0
- data/spec/moneta/simple_activerecord_spec.rb +1 -0
- data/spec/moneta/simple_activerecord_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_cassandra_spec.rb +1 -0
- data/spec/moneta/simple_client_tcp_spec.rb +1 -0
- data/spec/moneta/simple_client_unix_spec.rb +3 -2
- data/spec/moneta/simple_couch_spec.rb +1 -0
- data/spec/moneta/simple_couch_with_expires_spec.rb +2 -1
- data/spec/moneta/simple_datamapper_spec.rb +1 -0
- data/spec/moneta/simple_datamapper_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_datamapper_with_repository_spec.rb +1 -0
- data/spec/moneta/simple_daybreak_spec.rb +1 -0
- data/spec/moneta/simple_daybreak_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_dbm_spec.rb +1 -0
- data/spec/moneta/simple_dbm_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_file_spec.rb +1 -0
- data/spec/moneta/simple_file_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_fog_spec.rb +1 -0
- data/spec/moneta/simple_fog_with_expires_spec.rb +2 -1
- data/spec/moneta/simple_gdbm_spec.rb +1 -0
- data/spec/moneta/simple_gdbm_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_hashfile_spec.rb +1 -0
- data/spec/moneta/simple_hashfile_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_hbase_spec.rb +1 -0
- data/spec/moneta/simple_hbase_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_leveldb_spec.rb +1 -0
- data/spec/moneta/simple_leveldb_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_localmemcache_spec.rb +1 -0
- data/spec/moneta/simple_localmemcache_with_expires_spec.rb +2 -1
- data/spec/moneta/simple_lruhash_spec.rb +1 -0
- data/spec/moneta/simple_lruhash_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_memcached_dalli_spec.rb +2 -0
- data/spec/moneta/simple_memcached_native_spec.rb +2 -0
- data/spec/moneta/simple_memcached_spec.rb +2 -0
- data/spec/moneta/simple_memory_spec.rb +1 -0
- data/spec/moneta/simple_memory_with_compress_spec.rb +1 -0
- data/spec/moneta/simple_memory_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_memory_with_json_key_serializer_spec.rb +1 -0
- data/spec/moneta/simple_memory_with_json_serializer_spec.rb +1 -0
- data/spec/moneta/simple_memory_with_json_value_serializer_spec.rb +1 -0
- data/spec/moneta/simple_memory_with_prefix_spec.rb +1 -0
- data/spec/moneta/simple_memory_with_snappy_compress_spec.rb +1 -0
- data/spec/moneta/simple_mongo_spec.rb +2 -0
- data/spec/moneta/simple_null_spec.rb +1 -0
- data/spec/moneta/simple_pstore_spec.rb +1 -0
- data/spec/moneta/simple_pstore_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_redis_spec.rb +2 -0
- data/spec/moneta/simple_restclient_spec.rb +1 -0
- data/spec/moneta/simple_riak_spec.rb +1 -0
- data/spec/moneta/simple_riak_with_expires_spec.rb +2 -1
- data/spec/moneta/simple_sdbm_spec.rb +1 -0
- data/spec/moneta/simple_sdbm_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_sequel_spec.rb +1 -0
- data/spec/moneta/simple_sequel_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_sqlite_spec.rb +1 -0
- data/spec/moneta/simple_sqlite_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_tdb_spec.rb +1 -0
- data/spec/moneta/simple_tdb_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_tokyocabinet_spec.rb +1 -0
- data/spec/moneta/simple_tokyocabinet_with_expires_spec.rb +3 -1
- data/spec/moneta/simple_yaml_spec.rb +1 -0
- data/spec/moneta/simple_yaml_with_expires_spec.rb +3 -1
- data/spec/moneta/stack_file_memory_spec.rb +1 -0
- data/spec/moneta/stack_memory_file_spec.rb +1 -0
- data/spec/moneta/transformer_bencode_spec.rb +1 -0
- data/spec/moneta/transformer_bert_spec.rb +1 -0
- data/spec/moneta/transformer_bson_spec.rb +1 -0
- data/spec/moneta/transformer_bzip2_spec.rb +1 -0
- data/spec/moneta/transformer_json_spec.rb +1 -0
- data/spec/moneta/transformer_key_inspect_spec.rb +73 -0
- data/spec/moneta/transformer_key_marshal_spec.rb +1 -0
- data/spec/moneta/transformer_key_to_s_spec.rb +1 -0
- data/spec/moneta/transformer_key_yaml_spec.rb +1 -0
- data/spec/moneta/transformer_lzma_spec.rb +1 -0
- data/spec/moneta/transformer_lzo_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_base64_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_escape_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_hmac_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_md5_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_md5_spread_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_prefix_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_rmd160_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_sha1_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_sha256_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_sha384_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_sha512_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_truncate_spec.rb +1 -0
- data/spec/moneta/transformer_marshal_uuencode_spec.rb +1 -0
- data/spec/moneta/transformer_msgpack_spec.rb +1 -0
- data/spec/moneta/transformer_ox_spec.rb +1 -0
- data/spec/moneta/transformer_quicklz_spec.rb +1 -0
- data/spec/moneta/transformer_snappy_spec.rb +1 -0
- data/spec/moneta/transformer_tnet_spec.rb +1 -0
- data/spec/moneta/transformer_value_marshal_spec.rb +1 -0
- data/spec/moneta/transformer_value_yaml_spec.rb +1 -0
- data/spec/moneta/transformer_yaml_spec.rb +1 -0
- data/spec/moneta/transformer_zlib_spec.rb +1 -0
- data/spec/moneta/weak_create_spec.rb +114 -0
- data/spec/moneta/weak_increment_spec.rb +114 -0
- data/spec/monetaspecs.rb +75 -2
- data/spec/rack/moneta_cookies_spec.rb +1 -1
- metadata +20 -4
data/script/install-bundle
CHANGED
@@ -18,9 +18,9 @@ BUNDLE_FILE = "moneta-bundle-#{RUBY_VERSION}-#{ruby}.tar.gz"
|
|
18
18
|
|
19
19
|
if system("wget --no-check-certificate --quiet -O #{BUNDLE_FILE} https://moneta:#{ENV['DAV_PW']}@mendler.net/dav/#{BUNDLE_FILE}")
|
20
20
|
cmd 'rm -rf .bundle'
|
21
|
-
cmd "tar -
|
21
|
+
cmd "tar -xpf #{BUNDLE_FILE}"
|
22
22
|
cmd "rm -f #{BUNDLE_FILE}"
|
23
23
|
else
|
24
24
|
cmd 'bundle install --path .bundle'
|
25
|
-
cmd "tar -
|
25
|
+
cmd "tar -cpzf #{BUNDLE_FILE} .bundle"
|
26
26
|
end
|
@@ -17,6 +17,7 @@ describe_moneta "adapter_cassandra" do
|
|
17
17
|
include_context 'setup_store'
|
18
18
|
it_should_behave_like 'expires'
|
19
19
|
it_should_behave_like 'multiprocess'
|
20
|
+
it_should_behave_like 'not_create'
|
20
21
|
it_should_behave_like 'not_increment'
|
21
22
|
it_should_behave_like 'null_stringkey_stringvalue'
|
22
23
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
@@ -18,6 +18,7 @@ describe_moneta "adapter_cassandra_with_default_expires" do
|
|
18
18
|
it_should_behave_like 'default_expires'
|
19
19
|
it_should_behave_like 'expires'
|
20
20
|
it_should_behave_like 'multiprocess'
|
21
|
+
it_should_behave_like 'not_create'
|
21
22
|
it_should_behave_like 'not_increment'
|
22
23
|
it_should_behave_like 'null_stringkey_stringvalue'
|
23
24
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
@@ -16,6 +16,7 @@ describe_moneta "adapter_couch" do
|
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
18
|
it_should_behave_like 'multiprocess'
|
19
|
+
it_should_behave_like 'not_create'
|
19
20
|
it_should_behave_like 'not_increment'
|
20
21
|
it_should_behave_like 'null_stringkey_stringvalue'
|
21
22
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
@@ -15,6 +15,7 @@ describe_moneta "adapter_daybreak" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
18
19
|
it_should_behave_like 'increment'
|
19
20
|
it_should_behave_like 'null_stringkey_stringvalue'
|
20
21
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
@@ -21,6 +21,7 @@ describe_moneta "adapter_fog" do
|
|
21
21
|
|
22
22
|
include_context 'setup_store'
|
23
23
|
it_should_behave_like 'multiprocess'
|
24
|
+
it_should_behave_like 'not_create'
|
24
25
|
it_should_behave_like 'not_increment'
|
25
26
|
it_should_behave_like 'null_stringkey_stringvalue'
|
26
27
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
@@ -15,8 +15,8 @@ describe_moneta "adapter_gdbm" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
18
19
|
it_should_behave_like 'increment'
|
19
|
-
it_should_behave_like 'multiprocess'
|
20
20
|
it_should_behave_like 'null_stringkey_stringvalue'
|
21
21
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
22
22
|
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
@@ -17,6 +17,7 @@ describe_moneta "adapter_hbase" do
|
|
17
17
|
include_context 'setup_store'
|
18
18
|
it_should_behave_like 'increment'
|
19
19
|
it_should_behave_like 'multiprocess'
|
20
|
+
it_should_behave_like 'not_create'
|
20
21
|
it_should_behave_like 'null_stringkey_stringvalue'
|
21
22
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
22
23
|
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
@@ -16,6 +16,7 @@ describe_moneta "adapter_localmemcache" do
|
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
18
|
it_should_behave_like 'multiprocess'
|
19
|
+
it_should_behave_like 'not_create'
|
19
20
|
it_should_behave_like 'not_increment'
|
20
21
|
it_should_behave_like 'null_stringkey_stringvalue'
|
21
22
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
@@ -15,6 +15,8 @@ describe_moneta "adapter_memcached_dalli" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
19
|
+
it_should_behave_like 'create_expires'
|
18
20
|
it_should_behave_like 'expires'
|
19
21
|
it_should_behave_like 'increment'
|
20
22
|
it_should_behave_like 'multiprocess'
|
@@ -15,6 +15,8 @@ describe_moneta "adapter_memcached_dalli_with_default_expires" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
19
|
+
it_should_behave_like 'create_expires'
|
18
20
|
it_should_behave_like 'default_expires'
|
19
21
|
it_should_behave_like 'expires'
|
20
22
|
it_should_behave_like 'increment'
|
@@ -15,6 +15,8 @@ describe_moneta "adapter_memcached_native" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
19
|
+
it_should_behave_like 'create_expires'
|
18
20
|
it_should_behave_like 'expires'
|
19
21
|
it_should_behave_like 'increment'
|
20
22
|
it_should_behave_like 'multiprocess'
|
@@ -15,6 +15,8 @@ describe_moneta "adapter_memcached_native_with_default_expires" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
19
|
+
it_should_behave_like 'create_expires'
|
18
20
|
it_should_behave_like 'default_expires'
|
19
21
|
it_should_behave_like 'expires'
|
20
22
|
it_should_behave_like 'increment'
|
@@ -15,6 +15,8 @@ describe_moneta "adapter_memcached" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
19
|
+
it_should_behave_like 'create_expires'
|
18
20
|
it_should_behave_like 'expires'
|
19
21
|
it_should_behave_like 'increment'
|
20
22
|
it_should_behave_like 'multiprocess'
|
@@ -15,6 +15,8 @@ describe_moneta "adapter_memcached_with_default_expires" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
19
|
+
it_should_behave_like 'create_expires'
|
18
20
|
it_should_behave_like 'default_expires'
|
19
21
|
it_should_behave_like 'expires'
|
20
22
|
it_should_behave_like 'increment'
|
@@ -15,6 +15,8 @@ describe_moneta "adapter_mongo" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
19
|
+
it_should_behave_like 'create_expires'
|
18
20
|
it_should_behave_like 'expires'
|
19
21
|
it_should_behave_like 'increment'
|
20
22
|
it_should_behave_like 'multiprocess'
|
@@ -15,6 +15,8 @@ describe_moneta "adapter_mongo_with_default_expires" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
19
|
+
it_should_behave_like 'create_expires'
|
18
20
|
it_should_behave_like 'default_expires'
|
19
21
|
it_should_behave_like 'expires'
|
20
22
|
it_should_behave_like 'increment'
|
@@ -15,6 +15,8 @@ describe_moneta "adapter_redis" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
19
|
+
it_should_behave_like 'create_expires'
|
18
20
|
it_should_behave_like 'expires'
|
19
21
|
it_should_behave_like 'increment'
|
20
22
|
it_should_behave_like 'multiprocess'
|
@@ -15,6 +15,8 @@ describe_moneta "adapter_redis_with_default_expires" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
19
|
+
it_should_behave_like 'create_expires'
|
18
20
|
it_should_behave_like 'default_expires'
|
19
21
|
it_should_behave_like 'expires'
|
20
22
|
it_should_behave_like 'increment'
|
@@ -17,6 +17,7 @@ describe_moneta "adapter_restclient" do
|
|
17
17
|
|
18
18
|
include_context 'setup_store'
|
19
19
|
it_should_behave_like 'multiprocess'
|
20
|
+
it_should_behave_like 'not_create'
|
20
21
|
it_should_behave_like 'not_increment'
|
21
22
|
it_should_behave_like 'null_stringkey_stringvalue'
|
22
23
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
@@ -20,6 +20,7 @@ describe_moneta "adapter_riak" do
|
|
20
20
|
|
21
21
|
include_context 'setup_store'
|
22
22
|
it_should_behave_like 'multiprocess'
|
23
|
+
it_should_behave_like 'not_create'
|
23
24
|
it_should_behave_like 'not_increment'
|
24
25
|
it_should_behave_like 'null_stringkey_stringvalue'
|
25
26
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
@@ -15,6 +15,7 @@ describe_moneta "adapter_tokyocabinet_bdb" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
18
19
|
it_should_behave_like 'increment'
|
19
20
|
it_should_behave_like 'null_stringkey_stringvalue'
|
20
21
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
@@ -15,6 +15,7 @@ describe_moneta "adapter_tokyocabinet_hdb" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
include_context 'setup_store'
|
18
|
+
it_should_behave_like 'create'
|
18
19
|
it_should_behave_like 'increment'
|
19
20
|
it_should_behave_like 'null_stringkey_stringvalue'
|
20
21
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
@@ -19,6 +19,8 @@ describe_moneta "expires_file" do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
include_context 'setup_store'
|
22
|
+
it_should_behave_like 'create'
|
23
|
+
it_should_behave_like 'create_expires'
|
22
24
|
it_should_behave_like 'expires'
|
23
25
|
it_should_behave_like 'increment'
|
24
26
|
it_should_behave_like 'marshallable_key'
|
@@ -48,7 +50,7 @@ describe_moneta "expires_file" do
|
|
48
50
|
it_should_behave_like 'store_booleankey_stringvalue'
|
49
51
|
it_should_behave_like 'store_nilkey_stringvalue'
|
50
52
|
it_should_behave_like 'store_integerkey_stringvalue'
|
51
|
-
it_should_behave_like '
|
53
|
+
it_should_behave_like 'transform_value_expires'
|
52
54
|
it 'deletes expired value in underlying file storage' do
|
53
55
|
store.store('foo', 'bar', :expires => 2)
|
54
56
|
store['foo'].should == 'bar'
|
@@ -18,6 +18,8 @@ describe_moneta "expires_memory" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
include_context 'setup_store'
|
21
|
+
it_should_behave_like 'create'
|
22
|
+
it_should_behave_like 'create_expires'
|
21
23
|
it_should_behave_like 'expires'
|
22
24
|
it_should_behave_like 'increment'
|
23
25
|
it_should_behave_like 'not_persist'
|
@@ -18,6 +18,8 @@ describe_moneta "expires_memory_with_default_expires" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
include_context 'setup_store'
|
21
|
+
it_should_behave_like 'create'
|
22
|
+
it_should_behave_like 'create_expires'
|
21
23
|
it_should_behave_like 'default_expires'
|
22
24
|
it_should_behave_like 'expires'
|
23
25
|
it_should_behave_like 'increment'
|
data/spec/moneta/lock_spec.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Generated by generate-specs
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "mutex" do
|
5
|
+
def log
|
6
|
+
@log ||= File.open(File.join(make_tempdir, 'mutex.log'), 'a')
|
7
|
+
end
|
8
|
+
|
9
|
+
def new_store
|
10
|
+
Moneta.new(:Memory, :logger => {:out => log})
|
11
|
+
end
|
12
|
+
|
13
|
+
def load_value(value)
|
14
|
+
Marshal.load(value)
|
15
|
+
end
|
16
|
+
|
17
|
+
include_context 'setup_store'
|
18
|
+
|
19
|
+
it 'should have #lock' do
|
20
|
+
mutex = Moneta::Mutex.new(store, 'mutex')
|
21
|
+
mutex.lock.should be_true
|
22
|
+
mutex.locked?.should be_true
|
23
|
+
expect do
|
24
|
+
mutex.lock
|
25
|
+
end.to raise_error(RuntimeError)
|
26
|
+
expect do
|
27
|
+
mutex.try_lock
|
28
|
+
end.to raise_error(RuntimeError)
|
29
|
+
mutex.unlock.should be_nil
|
30
|
+
mutex.locked?.should be_false
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should have #enter' do
|
34
|
+
mutex = Moneta::Mutex.new(store, 'mutex')
|
35
|
+
mutex.enter.should be_true
|
36
|
+
mutex.locked?.should be_true
|
37
|
+
expect do
|
38
|
+
mutex.enter
|
39
|
+
end.to raise_error(RuntimeError)
|
40
|
+
expect do
|
41
|
+
mutex.try_enter
|
42
|
+
end.to raise_error(RuntimeError)
|
43
|
+
mutex.leave.should be_nil
|
44
|
+
mutex.locked?.should be_false
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should lock with #lock' do
|
48
|
+
a = Moneta::Mutex.new(store, 'mutex')
|
49
|
+
b = Moneta::Mutex.new(store, 'mutex')
|
50
|
+
a.lock.should be_true
|
51
|
+
b.try_lock.should be_false
|
52
|
+
a.unlock.should be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should have lock timeout' do
|
56
|
+
a = Moneta::Mutex.new(store, 'mutex')
|
57
|
+
b = Moneta::Mutex.new(store, 'mutex')
|
58
|
+
a.lock.should be_true
|
59
|
+
b.lock(1).should be_false
|
60
|
+
a.unlock.should be_nil
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should have #synchronize' do
|
64
|
+
mutex = Moneta::Mutex.new(store, 'mutex')
|
65
|
+
mutex.synchronize do
|
66
|
+
mutex.locked?.should be_true
|
67
|
+
end
|
68
|
+
mutex.locked?.should be_false
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|