moneta 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +17 -51
- data/CHANGES +13 -0
- data/Gemfile +4 -4
- data/README.md +79 -40
- data/Rakefile +40 -25
- data/benchmarks/run.rb +35 -5
- data/lib/moneta.rb +5 -5
- data/lib/moneta/adapters/activerecord.rb +4 -6
- data/lib/moneta/adapters/cassandra.rb +8 -11
- data/lib/moneta/adapters/couch.rb +3 -1
- data/lib/moneta/adapters/daybreak.rb +28 -0
- data/lib/moneta/adapters/fog.rb +3 -3
- data/lib/moneta/adapters/hbase.rb +2 -4
- data/lib/moneta/adapters/memcached/dalli.rb +8 -7
- data/lib/moneta/adapters/memcached/native.rb +8 -9
- data/lib/moneta/adapters/mongo.rb +42 -11
- data/lib/moneta/adapters/pstore.rb +4 -6
- data/lib/moneta/adapters/redis.rb +17 -10
- data/lib/moneta/adapters/restclient.rb +19 -10
- data/lib/moneta/adapters/sequel.rb +4 -6
- data/lib/moneta/adapters/tdb.rb +22 -0
- data/lib/moneta/expires.rb +28 -12
- data/lib/moneta/mixins.rb +64 -3
- data/lib/moneta/pool.rb +37 -0
- data/lib/moneta/proxy.rb +18 -7
- data/lib/moneta/server.rb +1 -1
- data/lib/moneta/shared.rb +2 -2
- data/lib/moneta/transformer/helper.rb +1 -1
- data/lib/moneta/version.rb +1 -1
- data/{spec/generate.rb → script/generate-specs.rb} +195 -91
- data/script/install-bundle.rb +35 -0
- data/spec/helper.rb +6 -0
- data/spec/moneta/adapter_activerecord_spec.rb +1 -1
- data/spec/moneta/adapter_cassandra_spec.rb +1 -12
- data/spec/moneta/adapter_cassandra_with_default_expires_spec.rb +21 -0
- data/spec/moneta/adapter_client_spec.rb +1 -1
- data/spec/moneta/adapter_cookie_spec.rb +1 -1
- data/spec/moneta/adapter_couch_spec.rb +1 -1
- data/spec/moneta/adapter_datamapper_spec.rb +1 -1
- data/spec/moneta/adapter_daybreak_spec.rb +19 -0
- data/spec/moneta/adapter_dbm_spec.rb +1 -1
- data/spec/moneta/adapter_file_spec.rb +1 -1
- data/spec/moneta/adapter_fog_spec.rb +1 -1
- data/spec/moneta/adapter_gdbm_spec.rb +1 -1
- data/spec/moneta/adapter_hbase_spec.rb +1 -1
- data/spec/moneta/adapter_leveldb_spec.rb +1 -1
- data/spec/moneta/adapter_localmemcache_spec.rb +1 -1
- data/spec/moneta/adapter_lruhash_spec.rb +1 -1
- data/spec/moneta/adapter_memcached_dalli_spec.rb +1 -12
- data/spec/moneta/adapter_memcached_dalli_with_default_expires_spec.rb +21 -0
- data/spec/moneta/adapter_memcached_native_spec.rb +1 -13
- data/spec/moneta/adapter_memcached_native_with_default_expires_spec.rb +21 -0
- data/spec/moneta/adapter_memcached_spec.rb +1 -12
- data/spec/moneta/adapter_memcached_with_default_expires_spec.rb +21 -0
- data/spec/moneta/adapter_memory_spec.rb +1 -1
- data/spec/moneta/adapter_mongo_spec.rb +9 -2
- data/spec/moneta/adapter_mongo_with_default_expires_spec.rb +21 -0
- data/spec/moneta/adapter_pstore_spec.rb +1 -1
- data/spec/moneta/adapter_redis_spec.rb +1 -12
- data/spec/moneta/adapter_redis_with_default_expires_spec.rb +21 -0
- data/spec/moneta/adapter_restclient_spec.rb +1 -1
- data/spec/moneta/adapter_riak_spec.rb +1 -1
- data/spec/moneta/adapter_sdbm_spec.rb +1 -1
- data/spec/moneta/adapter_sequel_spec.rb +1 -1
- data/spec/moneta/adapter_sqlite_spec.rb +1 -1
- data/spec/moneta/adapter_tdb_spec.rb +19 -0
- data/spec/moneta/adapter_tokyocabinet_bdb_spec.rb +1 -1
- data/spec/moneta/adapter_tokyocabinet_hdb_spec.rb +1 -1
- data/spec/moneta/adapter_yaml_spec.rb +1 -1
- data/spec/moneta/cache_file_memory_spec.rb +1 -1
- data/spec/moneta/cache_memory_null_spec.rb +1 -1
- data/spec/moneta/expires_file_spec.rb +1 -1
- data/spec/moneta/expires_memory_spec.rb +1 -12
- data/spec/moneta/expires_memory_with_default_expires_spec.rb +111 -0
- data/spec/moneta/lock_spec.rb +1 -1
- data/spec/moneta/null_adapter_spec.rb +1 -1
- data/spec/moneta/optionmerger_spec.rb +1 -1
- data/spec/moneta/pool_spec.rb +23 -0
- data/spec/moneta/proxy_expires_memory_spec.rb +1 -1
- data/spec/moneta/proxy_redis_spec.rb +1 -1
- data/spec/moneta/shared_spec.rb +1 -1
- data/spec/moneta/simple_activerecord_spec.rb +1 -1
- data/spec/moneta/simple_activerecord_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_cassandra_spec.rb +1 -1
- data/spec/moneta/simple_client_tcp_spec.rb +1 -1
- data/spec/moneta/simple_client_unix_spec.rb +1 -1
- data/spec/moneta/simple_couch_spec.rb +1 -1
- data/spec/moneta/simple_couch_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_datamapper_spec.rb +1 -1
- data/spec/moneta/simple_datamapper_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_datamapper_with_repository_spec.rb +1 -1
- data/spec/moneta/simple_daybreak_spec.rb +144 -0
- data/spec/moneta/simple_daybreak_with_expires_spec.rb +145 -0
- data/spec/moneta/simple_dbm_spec.rb +1 -1
- data/spec/moneta/simple_dbm_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_file_spec.rb +1 -1
- data/spec/moneta/simple_file_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_fog_spec.rb +1 -1
- data/spec/moneta/simple_fog_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_gdbm_spec.rb +1 -1
- data/spec/moneta/simple_gdbm_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_hashfile_spec.rb +1 -1
- data/spec/moneta/simple_hashfile_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_hbase_spec.rb +1 -1
- data/spec/moneta/simple_hbase_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_leveldb_spec.rb +1 -1
- data/spec/moneta/simple_leveldb_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_localmemcache_spec.rb +1 -1
- data/spec/moneta/simple_localmemcache_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_lruhash_spec.rb +1 -1
- data/spec/moneta/simple_lruhash_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_memcached_dalli_spec.rb +1 -1
- data/spec/moneta/simple_memcached_native_spec.rb +1 -1
- data/spec/moneta/simple_memcached_spec.rb +1 -1
- data/spec/moneta/simple_memory_spec.rb +1 -1
- data/spec/moneta/simple_memory_with_compress_spec.rb +1 -1
- data/spec/moneta/simple_memory_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_memory_with_json_key_serializer_spec.rb +1 -1
- data/spec/moneta/simple_memory_with_json_serializer_spec.rb +1 -1
- data/spec/moneta/simple_memory_with_json_value_serializer_spec.rb +1 -1
- data/spec/moneta/simple_memory_with_prefix_spec.rb +1 -1
- data/spec/moneta/simple_memory_with_snappy_compress_spec.rb +1 -1
- data/spec/moneta/simple_mongo_spec.rb +3 -2
- data/spec/moneta/simple_null_spec.rb +1 -1
- data/spec/moneta/simple_pstore_spec.rb +1 -1
- data/spec/moneta/simple_pstore_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_redis_spec.rb +1 -1
- data/spec/moneta/simple_restclient_spec.rb +1 -1
- data/spec/moneta/simple_riak_spec.rb +1 -1
- data/spec/moneta/simple_riak_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_sdbm_spec.rb +1 -1
- data/spec/moneta/simple_sdbm_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_sequel_spec.rb +1 -1
- data/spec/moneta/simple_sequel_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_sqlite_spec.rb +1 -1
- data/spec/moneta/simple_sqlite_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_tdb_spec.rb +144 -0
- data/spec/moneta/{simple_mongo_with_expires_spec.rb → simple_tdb_with_expires_spec.rb} +4 -4
- data/spec/moneta/simple_tokyocabinet_spec.rb +1 -1
- data/spec/moneta/simple_tokyocabinet_with_expires_spec.rb +1 -1
- data/spec/moneta/simple_yaml_spec.rb +1 -1
- data/spec/moneta/simple_yaml_with_expires_spec.rb +1 -1
- data/spec/moneta/stack_file_memory_spec.rb +1 -1
- data/spec/moneta/stack_memory_file_spec.rb +1 -1
- data/spec/moneta/transformer_bencode_spec.rb +1 -1
- data/spec/moneta/transformer_bert_spec.rb +1 -1
- data/spec/moneta/transformer_bson_spec.rb +1 -1
- data/spec/moneta/transformer_bzip2_spec.rb +1 -1
- data/spec/moneta/transformer_json_spec.rb +1 -1
- data/spec/moneta/transformer_key_marshal_spec.rb +1 -1
- data/spec/moneta/transformer_key_yaml_spec.rb +1 -1
- data/spec/moneta/transformer_lzma_spec.rb +1 -1
- data/spec/moneta/transformer_lzo_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_base64_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_escape_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_hmac_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_md5_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_md5_spread_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_prefix_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_rmd160_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_sha1_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_sha256_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_sha384_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_sha512_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_truncate_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_uuencode_spec.rb +1 -1
- data/spec/moneta/transformer_msgpack_spec.rb +1 -1
- data/spec/moneta/transformer_ox_spec.rb +1 -1
- data/spec/moneta/transformer_quicklz_spec.rb +1 -1
- data/spec/moneta/transformer_snappy_spec.rb +1 -1
- data/spec/moneta/transformer_tnet_spec.rb +1 -1
- data/spec/moneta/transformer_value_marshal_spec.rb +1 -1
- data/spec/moneta/transformer_value_yaml_spec.rb +1 -1
- data/spec/moneta/transformer_yaml_spec.rb +1 -1
- data/spec/moneta/transformer_zlib_spec.rb +1 -1
- data/spec/monetaspecs.rb +105 -3
- metadata +35 -6
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Inspired by https://coderwall.com/p/x8exja
|
3
|
+
|
4
|
+
def cmd(s)
|
5
|
+
puts s
|
6
|
+
system(s)
|
7
|
+
end
|
8
|
+
|
9
|
+
def cmd!(s)
|
10
|
+
cmd(s) || abort("#{s} failed")
|
11
|
+
end
|
12
|
+
|
13
|
+
BUNDLE_FILE = "bundle-#{RUBY_VERSION}-#{defined?(JRUBY_VERSION) ? 'jruby' : 'mri'}.tar.gz"
|
14
|
+
|
15
|
+
if cmd("wget -O #{BUNDLE_FILE} http://s3.amazonaws.com/minad-moneta/#{BUNDLE_FILE}")
|
16
|
+
cmd! 'rm -rf .bundle'
|
17
|
+
cmd! "tar -xf #{BUNDLE_FILE}"
|
18
|
+
cmd! 'bundle install --path .bundle'
|
19
|
+
else
|
20
|
+
$: << File.expand_path(File.join(__FILE__, '..', '..', 'lib'))
|
21
|
+
|
22
|
+
cmd! 'gem install --no-rdoc --no-ri fog'
|
23
|
+
require 'rubygems'
|
24
|
+
require 'fog'
|
25
|
+
require 'moneta'
|
26
|
+
|
27
|
+
store = Moneta::Adapters::Fog.new(:provider => 'AWS',
|
28
|
+
:aws_access_key_id => ENV['AWS_KEY_ID'],
|
29
|
+
:aws_secret_access_key => ENV['AWS_ACCESS_KEY'],
|
30
|
+
:dir => 'minad-moneta')
|
31
|
+
|
32
|
+
cmd! 'bundle install --path .bundle'
|
33
|
+
cmd! "tar -czf #{BUNDLE_FILE} .bundle"
|
34
|
+
store.store(BUNDLE_FILE, File.read(BUNDLE_FILE), :public => true)
|
35
|
+
end
|
data/spec/helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Generated by generate.rb
|
1
|
+
# Generated by generate-specs.rb
|
2
2
|
require 'helper'
|
3
3
|
|
4
4
|
describe_moneta "adapter_cassandra" do
|
@@ -17,15 +17,4 @@ describe_moneta "adapter_cassandra" do
|
|
17
17
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
18
18
|
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
19
19
|
it_should_behave_like 'store_stringkey_stringvalue'
|
20
|
-
it 'supports default expiration time' do
|
21
|
-
store = Moneta::Adapters::Cassandra.new(:expires => 2, :keyspace => 'adapter_cassandra')
|
22
|
-
store.store('key1', 'val1')
|
23
|
-
store.store('key2', 'val2', :expires => 60)
|
24
|
-
store.load('key1').should == 'val1'
|
25
|
-
sleep 1
|
26
|
-
store.load('key1').should == 'val1'
|
27
|
-
sleep 2
|
28
|
-
store.load('key1').should be_nil
|
29
|
-
store['key2'].should == 'val2'
|
30
|
-
end
|
31
20
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generated by generate-specs.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_cassandra_with_default_expires" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::Cassandra.new(:expires => 1)
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'default_expires'
|
15
|
+
it_should_behave_like 'expires'
|
16
|
+
it_should_behave_like 'not_increment'
|
17
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
+
it_should_behave_like 'persist_stringkey_stringvalue'
|
19
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Generated by generate-specs.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_daybreak" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::Daybreak.new(:file => File.join(make_tempdir, "adapter_daybreak"))
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'increment'
|
15
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'persist_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
18
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
19
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Generated by generate.rb
|
1
|
+
# Generated by generate-specs.rb
|
2
2
|
require 'helper'
|
3
3
|
|
4
4
|
describe_moneta "adapter_memcached_dalli" do
|
@@ -17,15 +17,4 @@ describe_moneta "adapter_memcached_dalli" do
|
|
17
17
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
18
18
|
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
19
19
|
it_should_behave_like 'store_stringkey_stringvalue'
|
20
|
-
it 'supports default expiration time' do
|
21
|
-
store = Moneta::Adapters::MemcachedDalli.new(:expires => 2, :namespace => "adapter_memcached_dalli")
|
22
|
-
store.store('key1', 'val1')
|
23
|
-
store.store('key2', 'val2', :expires => 60)
|
24
|
-
store.load('key1').should == 'val1'
|
25
|
-
sleep 1
|
26
|
-
store.load('key1').should == 'val1'
|
27
|
-
sleep 2
|
28
|
-
store.load('key1').should be_nil
|
29
|
-
store['key2'].should == 'val2'
|
30
|
-
end
|
31
20
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generated by generate-specs.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_memcached_dalli_with_default_expires" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::MemcachedDalli.new(:expires => 1)
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'default_expires'
|
15
|
+
it_should_behave_like 'expires'
|
16
|
+
it_should_behave_like 'increment'
|
17
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
+
it_should_behave_like 'persist_stringkey_stringvalue'
|
19
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
21
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Generated by generate.rb
|
1
|
+
# Generated by generate-specs.rb
|
2
2
|
require 'helper'
|
3
3
|
|
4
4
|
describe_moneta "adapter_memcached_native" do
|
@@ -17,16 +17,4 @@ describe_moneta "adapter_memcached_native" do
|
|
17
17
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
18
18
|
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
19
19
|
it_should_behave_like 'store_stringkey_stringvalue'
|
20
|
-
it 'supports default expiration time' do
|
21
|
-
store = Moneta::Adapters::MemcachedNative.new(:expires => 2, :namespace => "adapter_memcached_native")
|
22
|
-
store.store('key1', 'val1')
|
23
|
-
store.store('key2', 'val2', :expires => 60)
|
24
|
-
store.load('key1').should == 'val1'
|
25
|
-
sleep 1
|
26
|
-
store.load('key1').should == 'val1'
|
27
|
-
sleep 2
|
28
|
-
store.load('key1').should be_nil
|
29
|
-
store['key2'].should == 'val2'
|
30
|
-
end
|
31
|
-
|
32
20
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generated by generate-specs.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_memcached_native_with_default_expires" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::MemcachedNative.new(:expires => 1)
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'default_expires'
|
15
|
+
it_should_behave_like 'expires'
|
16
|
+
it_should_behave_like 'increment'
|
17
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
+
it_should_behave_like 'persist_stringkey_stringvalue'
|
19
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
21
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Generated by generate.rb
|
1
|
+
# Generated by generate-specs.rb
|
2
2
|
require 'helper'
|
3
3
|
|
4
4
|
describe_moneta "adapter_memcached" do
|
@@ -17,15 +17,4 @@ describe_moneta "adapter_memcached" do
|
|
17
17
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
18
18
|
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
19
19
|
it_should_behave_like 'store_stringkey_stringvalue'
|
20
|
-
it 'supports default expiration time' do
|
21
|
-
store = Moneta::Adapters::Memcached.new(:expires => 2, :namespace => "adapter_memcached")
|
22
|
-
store.store('key1', 'val1')
|
23
|
-
store.store('key2', 'val2', :expires => 60)
|
24
|
-
store.load('key1').should == 'val1'
|
25
|
-
sleep 1
|
26
|
-
store.load('key1').should == 'val1'
|
27
|
-
sleep 2
|
28
|
-
store.load('key1').should be_nil
|
29
|
-
store['key2'].should == 'val2'
|
30
|
-
end
|
31
20
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generated by generate-specs.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_memcached_with_default_expires" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::Memcached.new(:expires => 1)
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'default_expires'
|
15
|
+
it_should_behave_like 'expires'
|
16
|
+
it_should_behave_like 'increment'
|
17
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
+
it_should_behave_like 'persist_stringkey_stringvalue'
|
19
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
21
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Generated by generate.rb
|
1
|
+
# Generated by generate-specs.rb
|
2
2
|
require 'helper'
|
3
3
|
|
4
4
|
describe_moneta "adapter_mongo" do
|
@@ -11,9 +11,16 @@ describe_moneta "adapter_mongo" do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
include_context 'setup_store'
|
14
|
-
it_should_behave_like '
|
14
|
+
it_should_behave_like 'expires'
|
15
|
+
it_should_behave_like 'increment'
|
15
16
|
it_should_behave_like 'null_stringkey_stringvalue'
|
16
17
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
17
18
|
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
18
19
|
it_should_behave_like 'store_stringkey_stringvalue'
|
20
|
+
it 'automatically deletes expired document' do
|
21
|
+
store.store('key', 'val', :expires => 30)
|
22
|
+
store.instance_variable_get(:@collection).find_one('_id' => ::BSON::Binary.new('key')).should_not be_nil
|
23
|
+
sleep 70 # Mongo needs up to 60 seconds
|
24
|
+
store.instance_variable_get(:@collection).find_one('_id' => ::BSON::Binary.new('key')).should be_nil
|
25
|
+
end
|
19
26
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generated by generate-specs.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_mongo_with_default_expires" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::Mongo.new(:expires => 1)
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'default_expires'
|
15
|
+
it_should_behave_like 'expires'
|
16
|
+
it_should_behave_like 'increment'
|
17
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
+
it_should_behave_like 'persist_stringkey_stringvalue'
|
19
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
21
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Generated by generate.rb
|
1
|
+
# Generated by generate-specs.rb
|
2
2
|
require 'helper'
|
3
3
|
|
4
4
|
describe_moneta "adapter_redis" do
|
@@ -17,15 +17,4 @@ describe_moneta "adapter_redis" do
|
|
17
17
|
it_should_behave_like 'persist_stringkey_stringvalue'
|
18
18
|
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
19
19
|
it_should_behave_like 'store_stringkey_stringvalue'
|
20
|
-
it 'supports default expiration time' do
|
21
|
-
store = Moneta::Adapters::Redis.new(:expires => 2)
|
22
|
-
store.store('key1', 'val1')
|
23
|
-
store.store('key2', 'val2', :expires => 60)
|
24
|
-
store.load('key1').should == 'val1'
|
25
|
-
sleep 1
|
26
|
-
store.load('key1').should == 'val1'
|
27
|
-
sleep 2
|
28
|
-
store.load('key1').should be_nil
|
29
|
-
store['key2'].should == 'val2'
|
30
|
-
end
|
31
20
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Generated by generate-specs.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_redis_with_default_expires" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::Redis.new(:expires => 1)
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'default_expires'
|
15
|
+
it_should_behave_like 'expires'
|
16
|
+
it_should_behave_like 'increment'
|
17
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
+
it_should_behave_like 'persist_stringkey_stringvalue'
|
19
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
21
|
+
end
|