moneta 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data/.travis.yml +17 -51
  2. data/CHANGES +13 -0
  3. data/Gemfile +4 -4
  4. data/README.md +79 -40
  5. data/Rakefile +40 -25
  6. data/benchmarks/run.rb +35 -5
  7. data/lib/moneta.rb +5 -5
  8. data/lib/moneta/adapters/activerecord.rb +4 -6
  9. data/lib/moneta/adapters/cassandra.rb +8 -11
  10. data/lib/moneta/adapters/couch.rb +3 -1
  11. data/lib/moneta/adapters/daybreak.rb +28 -0
  12. data/lib/moneta/adapters/fog.rb +3 -3
  13. data/lib/moneta/adapters/hbase.rb +2 -4
  14. data/lib/moneta/adapters/memcached/dalli.rb +8 -7
  15. data/lib/moneta/adapters/memcached/native.rb +8 -9
  16. data/lib/moneta/adapters/mongo.rb +42 -11
  17. data/lib/moneta/adapters/pstore.rb +4 -6
  18. data/lib/moneta/adapters/redis.rb +17 -10
  19. data/lib/moneta/adapters/restclient.rb +19 -10
  20. data/lib/moneta/adapters/sequel.rb +4 -6
  21. data/lib/moneta/adapters/tdb.rb +22 -0
  22. data/lib/moneta/expires.rb +28 -12
  23. data/lib/moneta/mixins.rb +64 -3
  24. data/lib/moneta/pool.rb +37 -0
  25. data/lib/moneta/proxy.rb +18 -7
  26. data/lib/moneta/server.rb +1 -1
  27. data/lib/moneta/shared.rb +2 -2
  28. data/lib/moneta/transformer/helper.rb +1 -1
  29. data/lib/moneta/version.rb +1 -1
  30. data/{spec/generate.rb → script/generate-specs.rb} +195 -91
  31. data/script/install-bundle.rb +35 -0
  32. data/spec/helper.rb +6 -0
  33. data/spec/moneta/adapter_activerecord_spec.rb +1 -1
  34. data/spec/moneta/adapter_cassandra_spec.rb +1 -12
  35. data/spec/moneta/adapter_cassandra_with_default_expires_spec.rb +21 -0
  36. data/spec/moneta/adapter_client_spec.rb +1 -1
  37. data/spec/moneta/adapter_cookie_spec.rb +1 -1
  38. data/spec/moneta/adapter_couch_spec.rb +1 -1
  39. data/spec/moneta/adapter_datamapper_spec.rb +1 -1
  40. data/spec/moneta/adapter_daybreak_spec.rb +19 -0
  41. data/spec/moneta/adapter_dbm_spec.rb +1 -1
  42. data/spec/moneta/adapter_file_spec.rb +1 -1
  43. data/spec/moneta/adapter_fog_spec.rb +1 -1
  44. data/spec/moneta/adapter_gdbm_spec.rb +1 -1
  45. data/spec/moneta/adapter_hbase_spec.rb +1 -1
  46. data/spec/moneta/adapter_leveldb_spec.rb +1 -1
  47. data/spec/moneta/adapter_localmemcache_spec.rb +1 -1
  48. data/spec/moneta/adapter_lruhash_spec.rb +1 -1
  49. data/spec/moneta/adapter_memcached_dalli_spec.rb +1 -12
  50. data/spec/moneta/adapter_memcached_dalli_with_default_expires_spec.rb +21 -0
  51. data/spec/moneta/adapter_memcached_native_spec.rb +1 -13
  52. data/spec/moneta/adapter_memcached_native_with_default_expires_spec.rb +21 -0
  53. data/spec/moneta/adapter_memcached_spec.rb +1 -12
  54. data/spec/moneta/adapter_memcached_with_default_expires_spec.rb +21 -0
  55. data/spec/moneta/adapter_memory_spec.rb +1 -1
  56. data/spec/moneta/adapter_mongo_spec.rb +9 -2
  57. data/spec/moneta/adapter_mongo_with_default_expires_spec.rb +21 -0
  58. data/spec/moneta/adapter_pstore_spec.rb +1 -1
  59. data/spec/moneta/adapter_redis_spec.rb +1 -12
  60. data/spec/moneta/adapter_redis_with_default_expires_spec.rb +21 -0
  61. data/spec/moneta/adapter_restclient_spec.rb +1 -1
  62. data/spec/moneta/adapter_riak_spec.rb +1 -1
  63. data/spec/moneta/adapter_sdbm_spec.rb +1 -1
  64. data/spec/moneta/adapter_sequel_spec.rb +1 -1
  65. data/spec/moneta/adapter_sqlite_spec.rb +1 -1
  66. data/spec/moneta/adapter_tdb_spec.rb +19 -0
  67. data/spec/moneta/adapter_tokyocabinet_bdb_spec.rb +1 -1
  68. data/spec/moneta/adapter_tokyocabinet_hdb_spec.rb +1 -1
  69. data/spec/moneta/adapter_yaml_spec.rb +1 -1
  70. data/spec/moneta/cache_file_memory_spec.rb +1 -1
  71. data/spec/moneta/cache_memory_null_spec.rb +1 -1
  72. data/spec/moneta/expires_file_spec.rb +1 -1
  73. data/spec/moneta/expires_memory_spec.rb +1 -12
  74. data/spec/moneta/expires_memory_with_default_expires_spec.rb +111 -0
  75. data/spec/moneta/lock_spec.rb +1 -1
  76. data/spec/moneta/null_adapter_spec.rb +1 -1
  77. data/spec/moneta/optionmerger_spec.rb +1 -1
  78. data/spec/moneta/pool_spec.rb +23 -0
  79. data/spec/moneta/proxy_expires_memory_spec.rb +1 -1
  80. data/spec/moneta/proxy_redis_spec.rb +1 -1
  81. data/spec/moneta/shared_spec.rb +1 -1
  82. data/spec/moneta/simple_activerecord_spec.rb +1 -1
  83. data/spec/moneta/simple_activerecord_with_expires_spec.rb +1 -1
  84. data/spec/moneta/simple_cassandra_spec.rb +1 -1
  85. data/spec/moneta/simple_client_tcp_spec.rb +1 -1
  86. data/spec/moneta/simple_client_unix_spec.rb +1 -1
  87. data/spec/moneta/simple_couch_spec.rb +1 -1
  88. data/spec/moneta/simple_couch_with_expires_spec.rb +1 -1
  89. data/spec/moneta/simple_datamapper_spec.rb +1 -1
  90. data/spec/moneta/simple_datamapper_with_expires_spec.rb +1 -1
  91. data/spec/moneta/simple_datamapper_with_repository_spec.rb +1 -1
  92. data/spec/moneta/simple_daybreak_spec.rb +144 -0
  93. data/spec/moneta/simple_daybreak_with_expires_spec.rb +145 -0
  94. data/spec/moneta/simple_dbm_spec.rb +1 -1
  95. data/spec/moneta/simple_dbm_with_expires_spec.rb +1 -1
  96. data/spec/moneta/simple_file_spec.rb +1 -1
  97. data/spec/moneta/simple_file_with_expires_spec.rb +1 -1
  98. data/spec/moneta/simple_fog_spec.rb +1 -1
  99. data/spec/moneta/simple_fog_with_expires_spec.rb +1 -1
  100. data/spec/moneta/simple_gdbm_spec.rb +1 -1
  101. data/spec/moneta/simple_gdbm_with_expires_spec.rb +1 -1
  102. data/spec/moneta/simple_hashfile_spec.rb +1 -1
  103. data/spec/moneta/simple_hashfile_with_expires_spec.rb +1 -1
  104. data/spec/moneta/simple_hbase_spec.rb +1 -1
  105. data/spec/moneta/simple_hbase_with_expires_spec.rb +1 -1
  106. data/spec/moneta/simple_leveldb_spec.rb +1 -1
  107. data/spec/moneta/simple_leveldb_with_expires_spec.rb +1 -1
  108. data/spec/moneta/simple_localmemcache_spec.rb +1 -1
  109. data/spec/moneta/simple_localmemcache_with_expires_spec.rb +1 -1
  110. data/spec/moneta/simple_lruhash_spec.rb +1 -1
  111. data/spec/moneta/simple_lruhash_with_expires_spec.rb +1 -1
  112. data/spec/moneta/simple_memcached_dalli_spec.rb +1 -1
  113. data/spec/moneta/simple_memcached_native_spec.rb +1 -1
  114. data/spec/moneta/simple_memcached_spec.rb +1 -1
  115. data/spec/moneta/simple_memory_spec.rb +1 -1
  116. data/spec/moneta/simple_memory_with_compress_spec.rb +1 -1
  117. data/spec/moneta/simple_memory_with_expires_spec.rb +1 -1
  118. data/spec/moneta/simple_memory_with_json_key_serializer_spec.rb +1 -1
  119. data/spec/moneta/simple_memory_with_json_serializer_spec.rb +1 -1
  120. data/spec/moneta/simple_memory_with_json_value_serializer_spec.rb +1 -1
  121. data/spec/moneta/simple_memory_with_prefix_spec.rb +1 -1
  122. data/spec/moneta/simple_memory_with_snappy_compress_spec.rb +1 -1
  123. data/spec/moneta/simple_mongo_spec.rb +3 -2
  124. data/spec/moneta/simple_null_spec.rb +1 -1
  125. data/spec/moneta/simple_pstore_spec.rb +1 -1
  126. data/spec/moneta/simple_pstore_with_expires_spec.rb +1 -1
  127. data/spec/moneta/simple_redis_spec.rb +1 -1
  128. data/spec/moneta/simple_restclient_spec.rb +1 -1
  129. data/spec/moneta/simple_riak_spec.rb +1 -1
  130. data/spec/moneta/simple_riak_with_expires_spec.rb +1 -1
  131. data/spec/moneta/simple_sdbm_spec.rb +1 -1
  132. data/spec/moneta/simple_sdbm_with_expires_spec.rb +1 -1
  133. data/spec/moneta/simple_sequel_spec.rb +1 -1
  134. data/spec/moneta/simple_sequel_with_expires_spec.rb +1 -1
  135. data/spec/moneta/simple_sqlite_spec.rb +1 -1
  136. data/spec/moneta/simple_sqlite_with_expires_spec.rb +1 -1
  137. data/spec/moneta/simple_tdb_spec.rb +144 -0
  138. data/spec/moneta/{simple_mongo_with_expires_spec.rb → simple_tdb_with_expires_spec.rb} +4 -4
  139. data/spec/moneta/simple_tokyocabinet_spec.rb +1 -1
  140. data/spec/moneta/simple_tokyocabinet_with_expires_spec.rb +1 -1
  141. data/spec/moneta/simple_yaml_spec.rb +1 -1
  142. data/spec/moneta/simple_yaml_with_expires_spec.rb +1 -1
  143. data/spec/moneta/stack_file_memory_spec.rb +1 -1
  144. data/spec/moneta/stack_memory_file_spec.rb +1 -1
  145. data/spec/moneta/transformer_bencode_spec.rb +1 -1
  146. data/spec/moneta/transformer_bert_spec.rb +1 -1
  147. data/spec/moneta/transformer_bson_spec.rb +1 -1
  148. data/spec/moneta/transformer_bzip2_spec.rb +1 -1
  149. data/spec/moneta/transformer_json_spec.rb +1 -1
  150. data/spec/moneta/transformer_key_marshal_spec.rb +1 -1
  151. data/spec/moneta/transformer_key_yaml_spec.rb +1 -1
  152. data/spec/moneta/transformer_lzma_spec.rb +1 -1
  153. data/spec/moneta/transformer_lzo_spec.rb +1 -1
  154. data/spec/moneta/transformer_marshal_base64_spec.rb +1 -1
  155. data/spec/moneta/transformer_marshal_escape_spec.rb +1 -1
  156. data/spec/moneta/transformer_marshal_hmac_spec.rb +1 -1
  157. data/spec/moneta/transformer_marshal_md5_spec.rb +1 -1
  158. data/spec/moneta/transformer_marshal_md5_spread_spec.rb +1 -1
  159. data/spec/moneta/transformer_marshal_prefix_spec.rb +1 -1
  160. data/spec/moneta/transformer_marshal_rmd160_spec.rb +1 -1
  161. data/spec/moneta/transformer_marshal_sha1_spec.rb +1 -1
  162. data/spec/moneta/transformer_marshal_sha256_spec.rb +1 -1
  163. data/spec/moneta/transformer_marshal_sha384_spec.rb +1 -1
  164. data/spec/moneta/transformer_marshal_sha512_spec.rb +1 -1
  165. data/spec/moneta/transformer_marshal_spec.rb +1 -1
  166. data/spec/moneta/transformer_marshal_truncate_spec.rb +1 -1
  167. data/spec/moneta/transformer_marshal_uuencode_spec.rb +1 -1
  168. data/spec/moneta/transformer_msgpack_spec.rb +1 -1
  169. data/spec/moneta/transformer_ox_spec.rb +1 -1
  170. data/spec/moneta/transformer_quicklz_spec.rb +1 -1
  171. data/spec/moneta/transformer_snappy_spec.rb +1 -1
  172. data/spec/moneta/transformer_tnet_spec.rb +1 -1
  173. data/spec/moneta/transformer_value_marshal_spec.rb +1 -1
  174. data/spec/moneta/transformer_value_yaml_spec.rb +1 -1
  175. data/spec/moneta/transformer_yaml_spec.rb +1 -1
  176. data/spec/moneta/transformer_zlib_spec.rb +1 -1
  177. data/spec/monetaspecs.rb +105 -3
  178. 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
@@ -9,6 +9,12 @@ RSpec::Core::Formatters::ProgressFormatter.class_eval do
9
9
  end
10
10
  end
11
11
 
12
+ RSpec.configure do |config|
13
+ config.color_enabled = true
14
+ config.tty = true
15
+ config.formatter = :progress
16
+ end
17
+
12
18
  class Value
13
19
  attr_accessor :x
14
20
  def initialize(x)
@@ -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_activerecord" do
@@ -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
@@ -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_client" do
@@ -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_cookie" do
@@ -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_couch" do
@@ -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_datamapper" do
@@ -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_dbm" do
@@ -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_file" do
@@ -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_fog" do
@@ -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_gdbm" do
@@ -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_hbase" do
@@ -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_leveldb" do
@@ -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_localmemcache" do
@@ -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_lruhash" do
@@ -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_memory" do
@@ -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 'not_increment'
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_pstore" do
@@ -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