moneta 0.7.6 → 0.7.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. data/CHANGES +15 -0
  2. data/README.md +160 -50
  3. data/Rakefile +11 -2
  4. data/SPEC.md +7 -2
  5. data/lib/moneta.rb +7 -1
  6. data/lib/moneta/adapters/activerecord.rb +27 -3
  7. data/lib/moneta/adapters/cassandra.rb +1 -1
  8. data/lib/moneta/adapters/client.rb +8 -2
  9. data/lib/moneta/adapters/cookie.rb +1 -1
  10. data/lib/moneta/adapters/couch.rb +2 -1
  11. data/lib/moneta/adapters/datamapper.rb +16 -0
  12. data/lib/moneta/adapters/daybreak.rb +19 -1
  13. data/lib/moneta/adapters/file.rb +12 -0
  14. data/lib/moneta/adapters/hbase.rb +1 -2
  15. data/lib/moneta/adapters/lruhash.rb +4 -1
  16. data/lib/moneta/adapters/memcached.rb +7 -3
  17. data/lib/moneta/adapters/memcached/dalli.rb +8 -2
  18. data/lib/moneta/adapters/memcached/native.rb +10 -3
  19. data/lib/moneta/adapters/memory.rb +1 -0
  20. data/lib/moneta/adapters/mongo.rb +32 -5
  21. data/lib/moneta/adapters/pstore.rb +13 -2
  22. data/lib/moneta/adapters/redis.rb +19 -0
  23. data/lib/moneta/adapters/restclient.rb +1 -1
  24. data/lib/moneta/adapters/sequel.rb +20 -6
  25. data/lib/moneta/adapters/sqlite.rb +13 -1
  26. data/lib/moneta/adapters/tokyocabinet.rb +5 -0
  27. data/lib/moneta/cache.rb +10 -0
  28. data/lib/moneta/expires.rb +19 -22
  29. data/lib/moneta/lock.rb +2 -2
  30. data/lib/moneta/mixins.rb +33 -11
  31. data/lib/moneta/optionmerger.rb +1 -1
  32. data/lib/moneta/proxy.rb +13 -8
  33. data/lib/moneta/server.rb +13 -6
  34. data/lib/moneta/shared.rb +6 -10
  35. data/lib/moneta/synchronize.rb +125 -0
  36. data/lib/moneta/transformer.rb +50 -42
  37. data/lib/moneta/transformer/config.rb +34 -32
  38. data/lib/moneta/utils.rb +20 -0
  39. data/lib/moneta/version.rb +1 -1
  40. data/lib/moneta/weak.rb +17 -0
  41. data/lib/moneta/wrapper.rb +5 -0
  42. data/lib/rack/moneta_cookies.rb +2 -2
  43. data/lib/rack/moneta_store.rb +4 -4
  44. data/script/benchmarks +3 -9
  45. data/script/generate-specs +278 -41
  46. data/script/install-bundle +2 -2
  47. data/spec/moneta/adapter_activerecord_spec.rb +1 -0
  48. data/spec/moneta/adapter_cassandra_spec.rb +1 -0
  49. data/spec/moneta/adapter_cassandra_with_default_expires_spec.rb +1 -0
  50. data/spec/moneta/adapter_client_spec.rb +1 -0
  51. data/spec/moneta/adapter_cookie_spec.rb +1 -0
  52. data/spec/moneta/adapter_couch_spec.rb +1 -0
  53. data/spec/moneta/adapter_datamapper_spec.rb +1 -0
  54. data/spec/moneta/adapter_daybreak_spec.rb +1 -0
  55. data/spec/moneta/adapter_dbm_spec.rb +1 -0
  56. data/spec/moneta/adapter_file_spec.rb +1 -0
  57. data/spec/moneta/adapter_fog_spec.rb +1 -0
  58. data/spec/moneta/adapter_gdbm_spec.rb +1 -1
  59. data/spec/moneta/adapter_hbase_spec.rb +1 -0
  60. data/spec/moneta/adapter_leveldb_spec.rb +1 -0
  61. data/spec/moneta/adapter_localmemcache_spec.rb +1 -0
  62. data/spec/moneta/adapter_lruhash_spec.rb +1 -0
  63. data/spec/moneta/adapter_memcached_dalli_spec.rb +2 -0
  64. data/spec/moneta/adapter_memcached_dalli_with_default_expires_spec.rb +2 -0
  65. data/spec/moneta/adapter_memcached_native_spec.rb +2 -0
  66. data/spec/moneta/adapter_memcached_native_with_default_expires_spec.rb +2 -0
  67. data/spec/moneta/adapter_memcached_spec.rb +2 -0
  68. data/spec/moneta/adapter_memcached_with_default_expires_spec.rb +2 -0
  69. data/spec/moneta/adapter_memory_spec.rb +1 -0
  70. data/spec/moneta/adapter_mongo_spec.rb +2 -0
  71. data/spec/moneta/adapter_mongo_with_default_expires_spec.rb +2 -0
  72. data/spec/moneta/adapter_pstore_spec.rb +1 -0
  73. data/spec/moneta/adapter_redis_spec.rb +2 -0
  74. data/spec/moneta/adapter_redis_with_default_expires_spec.rb +2 -0
  75. data/spec/moneta/adapter_restclient_spec.rb +1 -0
  76. data/spec/moneta/adapter_riak_spec.rb +1 -0
  77. data/spec/moneta/adapter_sdbm_spec.rb +1 -0
  78. data/spec/moneta/adapter_sequel_spec.rb +1 -0
  79. data/spec/moneta/adapter_sqlite_spec.rb +1 -0
  80. data/spec/moneta/adapter_tdb_spec.rb +1 -0
  81. data/spec/moneta/adapter_tokyocabinet_bdb_spec.rb +1 -0
  82. data/spec/moneta/adapter_tokyocabinet_hdb_spec.rb +1 -0
  83. data/spec/moneta/adapter_yaml_spec.rb +1 -0
  84. data/spec/moneta/cache_file_memory_spec.rb +1 -0
  85. data/spec/moneta/cache_memory_null_spec.rb +1 -0
  86. data/spec/moneta/expires_file_spec.rb +3 -1
  87. data/spec/moneta/expires_memory_spec.rb +2 -0
  88. data/spec/moneta/expires_memory_with_default_expires_spec.rb +2 -0
  89. data/spec/moneta/lock_spec.rb +1 -0
  90. data/spec/moneta/mutex_spec.rb +71 -0
  91. data/spec/moneta/null_adapter_spec.rb +1 -0
  92. data/spec/moneta/optionmerger_spec.rb +5 -7
  93. data/spec/moneta/pool_spec.rb +1 -0
  94. data/spec/moneta/proxy_expires_memory_spec.rb +2 -0
  95. data/spec/moneta/proxy_redis_spec.rb +2 -0
  96. data/spec/moneta/semaphore_spec.rb +84 -0
  97. data/spec/moneta/{shared_spec.rb → shared_tcp_spec.rb} +4 -3
  98. data/spec/moneta/shared_unix_spec.rb +37 -0
  99. data/spec/moneta/simple_activerecord_spec.rb +1 -0
  100. data/spec/moneta/simple_activerecord_with_expires_spec.rb +3 -1
  101. data/spec/moneta/simple_cassandra_spec.rb +1 -0
  102. data/spec/moneta/simple_client_tcp_spec.rb +1 -0
  103. data/spec/moneta/simple_client_unix_spec.rb +3 -2
  104. data/spec/moneta/simple_couch_spec.rb +1 -0
  105. data/spec/moneta/simple_couch_with_expires_spec.rb +2 -1
  106. data/spec/moneta/simple_datamapper_spec.rb +1 -0
  107. data/spec/moneta/simple_datamapper_with_expires_spec.rb +3 -1
  108. data/spec/moneta/simple_datamapper_with_repository_spec.rb +1 -0
  109. data/spec/moneta/simple_daybreak_spec.rb +1 -0
  110. data/spec/moneta/simple_daybreak_with_expires_spec.rb +3 -1
  111. data/spec/moneta/simple_dbm_spec.rb +1 -0
  112. data/spec/moneta/simple_dbm_with_expires_spec.rb +3 -1
  113. data/spec/moneta/simple_file_spec.rb +1 -0
  114. data/spec/moneta/simple_file_with_expires_spec.rb +3 -1
  115. data/spec/moneta/simple_fog_spec.rb +1 -0
  116. data/spec/moneta/simple_fog_with_expires_spec.rb +2 -1
  117. data/spec/moneta/simple_gdbm_spec.rb +1 -0
  118. data/spec/moneta/simple_gdbm_with_expires_spec.rb +3 -1
  119. data/spec/moneta/simple_hashfile_spec.rb +1 -0
  120. data/spec/moneta/simple_hashfile_with_expires_spec.rb +3 -1
  121. data/spec/moneta/simple_hbase_spec.rb +1 -0
  122. data/spec/moneta/simple_hbase_with_expires_spec.rb +3 -1
  123. data/spec/moneta/simple_leveldb_spec.rb +1 -0
  124. data/spec/moneta/simple_leveldb_with_expires_spec.rb +3 -1
  125. data/spec/moneta/simple_localmemcache_spec.rb +1 -0
  126. data/spec/moneta/simple_localmemcache_with_expires_spec.rb +2 -1
  127. data/spec/moneta/simple_lruhash_spec.rb +1 -0
  128. data/spec/moneta/simple_lruhash_with_expires_spec.rb +3 -1
  129. data/spec/moneta/simple_memcached_dalli_spec.rb +2 -0
  130. data/spec/moneta/simple_memcached_native_spec.rb +2 -0
  131. data/spec/moneta/simple_memcached_spec.rb +2 -0
  132. data/spec/moneta/simple_memory_spec.rb +1 -0
  133. data/spec/moneta/simple_memory_with_compress_spec.rb +1 -0
  134. data/spec/moneta/simple_memory_with_expires_spec.rb +3 -1
  135. data/spec/moneta/simple_memory_with_json_key_serializer_spec.rb +1 -0
  136. data/spec/moneta/simple_memory_with_json_serializer_spec.rb +1 -0
  137. data/spec/moneta/simple_memory_with_json_value_serializer_spec.rb +1 -0
  138. data/spec/moneta/simple_memory_with_prefix_spec.rb +1 -0
  139. data/spec/moneta/simple_memory_with_snappy_compress_spec.rb +1 -0
  140. data/spec/moneta/simple_mongo_spec.rb +2 -0
  141. data/spec/moneta/simple_null_spec.rb +1 -0
  142. data/spec/moneta/simple_pstore_spec.rb +1 -0
  143. data/spec/moneta/simple_pstore_with_expires_spec.rb +3 -1
  144. data/spec/moneta/simple_redis_spec.rb +2 -0
  145. data/spec/moneta/simple_restclient_spec.rb +1 -0
  146. data/spec/moneta/simple_riak_spec.rb +1 -0
  147. data/spec/moneta/simple_riak_with_expires_spec.rb +2 -1
  148. data/spec/moneta/simple_sdbm_spec.rb +1 -0
  149. data/spec/moneta/simple_sdbm_with_expires_spec.rb +3 -1
  150. data/spec/moneta/simple_sequel_spec.rb +1 -0
  151. data/spec/moneta/simple_sequel_with_expires_spec.rb +3 -1
  152. data/spec/moneta/simple_sqlite_spec.rb +1 -0
  153. data/spec/moneta/simple_sqlite_with_expires_spec.rb +3 -1
  154. data/spec/moneta/simple_tdb_spec.rb +1 -0
  155. data/spec/moneta/simple_tdb_with_expires_spec.rb +3 -1
  156. data/spec/moneta/simple_tokyocabinet_spec.rb +1 -0
  157. data/spec/moneta/simple_tokyocabinet_with_expires_spec.rb +3 -1
  158. data/spec/moneta/simple_yaml_spec.rb +1 -0
  159. data/spec/moneta/simple_yaml_with_expires_spec.rb +3 -1
  160. data/spec/moneta/stack_file_memory_spec.rb +1 -0
  161. data/spec/moneta/stack_memory_file_spec.rb +1 -0
  162. data/spec/moneta/transformer_bencode_spec.rb +1 -0
  163. data/spec/moneta/transformer_bert_spec.rb +1 -0
  164. data/spec/moneta/transformer_bson_spec.rb +1 -0
  165. data/spec/moneta/transformer_bzip2_spec.rb +1 -0
  166. data/spec/moneta/transformer_json_spec.rb +1 -0
  167. data/spec/moneta/transformer_key_inspect_spec.rb +73 -0
  168. data/spec/moneta/transformer_key_marshal_spec.rb +1 -0
  169. data/spec/moneta/transformer_key_to_s_spec.rb +1 -0
  170. data/spec/moneta/transformer_key_yaml_spec.rb +1 -0
  171. data/spec/moneta/transformer_lzma_spec.rb +1 -0
  172. data/spec/moneta/transformer_lzo_spec.rb +1 -0
  173. data/spec/moneta/transformer_marshal_base64_spec.rb +1 -0
  174. data/spec/moneta/transformer_marshal_escape_spec.rb +1 -0
  175. data/spec/moneta/transformer_marshal_hmac_spec.rb +1 -0
  176. data/spec/moneta/transformer_marshal_md5_spec.rb +1 -0
  177. data/spec/moneta/transformer_marshal_md5_spread_spec.rb +1 -0
  178. data/spec/moneta/transformer_marshal_prefix_spec.rb +1 -0
  179. data/spec/moneta/transformer_marshal_rmd160_spec.rb +1 -0
  180. data/spec/moneta/transformer_marshal_sha1_spec.rb +1 -0
  181. data/spec/moneta/transformer_marshal_sha256_spec.rb +1 -0
  182. data/spec/moneta/transformer_marshal_sha384_spec.rb +1 -0
  183. data/spec/moneta/transformer_marshal_sha512_spec.rb +1 -0
  184. data/spec/moneta/transformer_marshal_spec.rb +1 -0
  185. data/spec/moneta/transformer_marshal_truncate_spec.rb +1 -0
  186. data/spec/moneta/transformer_marshal_uuencode_spec.rb +1 -0
  187. data/spec/moneta/transformer_msgpack_spec.rb +1 -0
  188. data/spec/moneta/transformer_ox_spec.rb +1 -0
  189. data/spec/moneta/transformer_quicklz_spec.rb +1 -0
  190. data/spec/moneta/transformer_snappy_spec.rb +1 -0
  191. data/spec/moneta/transformer_tnet_spec.rb +1 -0
  192. data/spec/moneta/transformer_value_marshal_spec.rb +1 -0
  193. data/spec/moneta/transformer_value_yaml_spec.rb +1 -0
  194. data/spec/moneta/transformer_yaml_spec.rb +1 -0
  195. data/spec/moneta/transformer_zlib_spec.rb +1 -0
  196. data/spec/moneta/weak_create_spec.rb +114 -0
  197. data/spec/moneta/weak_increment_spec.rb +114 -0
  198. data/spec/monetaspecs.rb +75 -2
  199. data/spec/rack/moneta_cookies_spec.rb +1 -1
  200. metadata +20 -4
@@ -0,0 +1,114 @@
1
+ # Generated by generate-specs
2
+ require 'helper'
3
+
4
+ describe_moneta "weak_create" do
5
+ def log
6
+ @log ||= File.open(File.join(make_tempdir, 'weak_create.log'), 'a')
7
+ end
8
+
9
+ def new_store
10
+ Moneta.build do
11
+ use :WeakCreate
12
+ adapter :Memory
13
+ end
14
+ end
15
+
16
+ def load_value(value)
17
+ Marshal.load(value)
18
+ end
19
+
20
+ include_context 'setup_store'
21
+ it_should_behave_like 'create'
22
+ it_should_behave_like 'increment'
23
+ it_should_behave_like 'not_persist'
24
+ it_should_behave_like 'null_objectkey_objectvalue'
25
+ it_should_behave_like 'null_objectkey_stringvalue'
26
+ it_should_behave_like 'null_objectkey_hashvalue'
27
+ it_should_behave_like 'null_objectkey_booleanvalue'
28
+ it_should_behave_like 'null_objectkey_nilvalue'
29
+ it_should_behave_like 'null_objectkey_integervalue'
30
+ it_should_behave_like 'null_stringkey_objectvalue'
31
+ it_should_behave_like 'null_stringkey_stringvalue'
32
+ it_should_behave_like 'null_stringkey_hashvalue'
33
+ it_should_behave_like 'null_stringkey_booleanvalue'
34
+ it_should_behave_like 'null_stringkey_nilvalue'
35
+ it_should_behave_like 'null_stringkey_integervalue'
36
+ it_should_behave_like 'null_hashkey_objectvalue'
37
+ it_should_behave_like 'null_hashkey_stringvalue'
38
+ it_should_behave_like 'null_hashkey_hashvalue'
39
+ it_should_behave_like 'null_hashkey_booleanvalue'
40
+ it_should_behave_like 'null_hashkey_nilvalue'
41
+ it_should_behave_like 'null_hashkey_integervalue'
42
+ it_should_behave_like 'null_booleankey_objectvalue'
43
+ it_should_behave_like 'null_booleankey_stringvalue'
44
+ it_should_behave_like 'null_booleankey_hashvalue'
45
+ it_should_behave_like 'null_booleankey_booleanvalue'
46
+ it_should_behave_like 'null_booleankey_nilvalue'
47
+ it_should_behave_like 'null_booleankey_integervalue'
48
+ it_should_behave_like 'null_nilkey_objectvalue'
49
+ it_should_behave_like 'null_nilkey_stringvalue'
50
+ it_should_behave_like 'null_nilkey_hashvalue'
51
+ it_should_behave_like 'null_nilkey_booleanvalue'
52
+ it_should_behave_like 'null_nilkey_nilvalue'
53
+ it_should_behave_like 'null_nilkey_integervalue'
54
+ it_should_behave_like 'null_integerkey_objectvalue'
55
+ it_should_behave_like 'null_integerkey_stringvalue'
56
+ it_should_behave_like 'null_integerkey_hashvalue'
57
+ it_should_behave_like 'null_integerkey_booleanvalue'
58
+ it_should_behave_like 'null_integerkey_nilvalue'
59
+ it_should_behave_like 'null_integerkey_integervalue'
60
+ it_should_behave_like 'returnsame_objectkey_objectvalue'
61
+ it_should_behave_like 'returnsame_objectkey_stringvalue'
62
+ it_should_behave_like 'returnsame_objectkey_hashvalue'
63
+ it_should_behave_like 'returnsame_stringkey_objectvalue'
64
+ it_should_behave_like 'returnsame_stringkey_stringvalue'
65
+ it_should_behave_like 'returnsame_stringkey_hashvalue'
66
+ it_should_behave_like 'returnsame_hashkey_objectvalue'
67
+ it_should_behave_like 'returnsame_hashkey_stringvalue'
68
+ it_should_behave_like 'returnsame_hashkey_hashvalue'
69
+ it_should_behave_like 'returnsame_booleankey_objectvalue'
70
+ it_should_behave_like 'returnsame_booleankey_stringvalue'
71
+ it_should_behave_like 'returnsame_booleankey_hashvalue'
72
+ it_should_behave_like 'returnsame_nilkey_objectvalue'
73
+ it_should_behave_like 'returnsame_nilkey_stringvalue'
74
+ it_should_behave_like 'returnsame_nilkey_hashvalue'
75
+ it_should_behave_like 'returnsame_integerkey_objectvalue'
76
+ it_should_behave_like 'returnsame_integerkey_stringvalue'
77
+ it_should_behave_like 'returnsame_integerkey_hashvalue'
78
+ it_should_behave_like 'store_objectkey_objectvalue'
79
+ it_should_behave_like 'store_objectkey_stringvalue'
80
+ it_should_behave_like 'store_objectkey_hashvalue'
81
+ it_should_behave_like 'store_objectkey_booleanvalue'
82
+ it_should_behave_like 'store_objectkey_nilvalue'
83
+ it_should_behave_like 'store_objectkey_integervalue'
84
+ it_should_behave_like 'store_stringkey_objectvalue'
85
+ it_should_behave_like 'store_stringkey_stringvalue'
86
+ it_should_behave_like 'store_stringkey_hashvalue'
87
+ it_should_behave_like 'store_stringkey_booleanvalue'
88
+ it_should_behave_like 'store_stringkey_nilvalue'
89
+ it_should_behave_like 'store_stringkey_integervalue'
90
+ it_should_behave_like 'store_hashkey_objectvalue'
91
+ it_should_behave_like 'store_hashkey_stringvalue'
92
+ it_should_behave_like 'store_hashkey_hashvalue'
93
+ it_should_behave_like 'store_hashkey_booleanvalue'
94
+ it_should_behave_like 'store_hashkey_nilvalue'
95
+ it_should_behave_like 'store_hashkey_integervalue'
96
+ it_should_behave_like 'store_booleankey_objectvalue'
97
+ it_should_behave_like 'store_booleankey_stringvalue'
98
+ it_should_behave_like 'store_booleankey_hashvalue'
99
+ it_should_behave_like 'store_booleankey_booleanvalue'
100
+ it_should_behave_like 'store_booleankey_nilvalue'
101
+ it_should_behave_like 'store_booleankey_integervalue'
102
+ it_should_behave_like 'store_nilkey_objectvalue'
103
+ it_should_behave_like 'store_nilkey_stringvalue'
104
+ it_should_behave_like 'store_nilkey_hashvalue'
105
+ it_should_behave_like 'store_nilkey_booleanvalue'
106
+ it_should_behave_like 'store_nilkey_nilvalue'
107
+ it_should_behave_like 'store_nilkey_integervalue'
108
+ it_should_behave_like 'store_integerkey_objectvalue'
109
+ it_should_behave_like 'store_integerkey_stringvalue'
110
+ it_should_behave_like 'store_integerkey_hashvalue'
111
+ it_should_behave_like 'store_integerkey_booleanvalue'
112
+ it_should_behave_like 'store_integerkey_nilvalue'
113
+ it_should_behave_like 'store_integerkey_integervalue'
114
+ end
@@ -0,0 +1,114 @@
1
+ # Generated by generate-specs
2
+ require 'helper'
3
+
4
+ describe_moneta "weak_increment" do
5
+ def log
6
+ @log ||= File.open(File.join(make_tempdir, 'weak_increment.log'), 'a')
7
+ end
8
+
9
+ def new_store
10
+ Moneta.build do
11
+ use :WeakIncrement
12
+ adapter :Memory
13
+ end
14
+ end
15
+
16
+ def load_value(value)
17
+ Marshal.load(value)
18
+ end
19
+
20
+ include_context 'setup_store'
21
+ it_should_behave_like 'create'
22
+ it_should_behave_like 'increment'
23
+ it_should_behave_like 'not_persist'
24
+ it_should_behave_like 'null_objectkey_objectvalue'
25
+ it_should_behave_like 'null_objectkey_stringvalue'
26
+ it_should_behave_like 'null_objectkey_hashvalue'
27
+ it_should_behave_like 'null_objectkey_booleanvalue'
28
+ it_should_behave_like 'null_objectkey_nilvalue'
29
+ it_should_behave_like 'null_objectkey_integervalue'
30
+ it_should_behave_like 'null_stringkey_objectvalue'
31
+ it_should_behave_like 'null_stringkey_stringvalue'
32
+ it_should_behave_like 'null_stringkey_hashvalue'
33
+ it_should_behave_like 'null_stringkey_booleanvalue'
34
+ it_should_behave_like 'null_stringkey_nilvalue'
35
+ it_should_behave_like 'null_stringkey_integervalue'
36
+ it_should_behave_like 'null_hashkey_objectvalue'
37
+ it_should_behave_like 'null_hashkey_stringvalue'
38
+ it_should_behave_like 'null_hashkey_hashvalue'
39
+ it_should_behave_like 'null_hashkey_booleanvalue'
40
+ it_should_behave_like 'null_hashkey_nilvalue'
41
+ it_should_behave_like 'null_hashkey_integervalue'
42
+ it_should_behave_like 'null_booleankey_objectvalue'
43
+ it_should_behave_like 'null_booleankey_stringvalue'
44
+ it_should_behave_like 'null_booleankey_hashvalue'
45
+ it_should_behave_like 'null_booleankey_booleanvalue'
46
+ it_should_behave_like 'null_booleankey_nilvalue'
47
+ it_should_behave_like 'null_booleankey_integervalue'
48
+ it_should_behave_like 'null_nilkey_objectvalue'
49
+ it_should_behave_like 'null_nilkey_stringvalue'
50
+ it_should_behave_like 'null_nilkey_hashvalue'
51
+ it_should_behave_like 'null_nilkey_booleanvalue'
52
+ it_should_behave_like 'null_nilkey_nilvalue'
53
+ it_should_behave_like 'null_nilkey_integervalue'
54
+ it_should_behave_like 'null_integerkey_objectvalue'
55
+ it_should_behave_like 'null_integerkey_stringvalue'
56
+ it_should_behave_like 'null_integerkey_hashvalue'
57
+ it_should_behave_like 'null_integerkey_booleanvalue'
58
+ it_should_behave_like 'null_integerkey_nilvalue'
59
+ it_should_behave_like 'null_integerkey_integervalue'
60
+ it_should_behave_like 'returnsame_objectkey_objectvalue'
61
+ it_should_behave_like 'returnsame_objectkey_stringvalue'
62
+ it_should_behave_like 'returnsame_objectkey_hashvalue'
63
+ it_should_behave_like 'returnsame_stringkey_objectvalue'
64
+ it_should_behave_like 'returnsame_stringkey_stringvalue'
65
+ it_should_behave_like 'returnsame_stringkey_hashvalue'
66
+ it_should_behave_like 'returnsame_hashkey_objectvalue'
67
+ it_should_behave_like 'returnsame_hashkey_stringvalue'
68
+ it_should_behave_like 'returnsame_hashkey_hashvalue'
69
+ it_should_behave_like 'returnsame_booleankey_objectvalue'
70
+ it_should_behave_like 'returnsame_booleankey_stringvalue'
71
+ it_should_behave_like 'returnsame_booleankey_hashvalue'
72
+ it_should_behave_like 'returnsame_nilkey_objectvalue'
73
+ it_should_behave_like 'returnsame_nilkey_stringvalue'
74
+ it_should_behave_like 'returnsame_nilkey_hashvalue'
75
+ it_should_behave_like 'returnsame_integerkey_objectvalue'
76
+ it_should_behave_like 'returnsame_integerkey_stringvalue'
77
+ it_should_behave_like 'returnsame_integerkey_hashvalue'
78
+ it_should_behave_like 'store_objectkey_objectvalue'
79
+ it_should_behave_like 'store_objectkey_stringvalue'
80
+ it_should_behave_like 'store_objectkey_hashvalue'
81
+ it_should_behave_like 'store_objectkey_booleanvalue'
82
+ it_should_behave_like 'store_objectkey_nilvalue'
83
+ it_should_behave_like 'store_objectkey_integervalue'
84
+ it_should_behave_like 'store_stringkey_objectvalue'
85
+ it_should_behave_like 'store_stringkey_stringvalue'
86
+ it_should_behave_like 'store_stringkey_hashvalue'
87
+ it_should_behave_like 'store_stringkey_booleanvalue'
88
+ it_should_behave_like 'store_stringkey_nilvalue'
89
+ it_should_behave_like 'store_stringkey_integervalue'
90
+ it_should_behave_like 'store_hashkey_objectvalue'
91
+ it_should_behave_like 'store_hashkey_stringvalue'
92
+ it_should_behave_like 'store_hashkey_hashvalue'
93
+ it_should_behave_like 'store_hashkey_booleanvalue'
94
+ it_should_behave_like 'store_hashkey_nilvalue'
95
+ it_should_behave_like 'store_hashkey_integervalue'
96
+ it_should_behave_like 'store_booleankey_objectvalue'
97
+ it_should_behave_like 'store_booleankey_stringvalue'
98
+ it_should_behave_like 'store_booleankey_hashvalue'
99
+ it_should_behave_like 'store_booleankey_booleanvalue'
100
+ it_should_behave_like 'store_booleankey_nilvalue'
101
+ it_should_behave_like 'store_booleankey_integervalue'
102
+ it_should_behave_like 'store_nilkey_objectvalue'
103
+ it_should_behave_like 'store_nilkey_stringvalue'
104
+ it_should_behave_like 'store_nilkey_hashvalue'
105
+ it_should_behave_like 'store_nilkey_booleanvalue'
106
+ it_should_behave_like 'store_nilkey_nilvalue'
107
+ it_should_behave_like 'store_nilkey_integervalue'
108
+ it_should_behave_like 'store_integerkey_objectvalue'
109
+ it_should_behave_like 'store_integerkey_stringvalue'
110
+ it_should_behave_like 'store_integerkey_hashvalue'
111
+ it_should_behave_like 'store_integerkey_booleanvalue'
112
+ it_should_behave_like 'store_integerkey_nilvalue'
113
+ it_should_behave_like 'store_integerkey_integervalue'
114
+ end
data/spec/monetaspecs.rb CHANGED
@@ -17186,6 +17186,79 @@ shared_examples_for 'increment' do
17186
17186
  store.decrement('strkey')
17187
17187
  end.to raise_error
17188
17188
  end
17189
+
17190
+ it 'supports Semaphore' do
17191
+ a = Moneta::Semaphore.new(store, 'semaphore', 2)
17192
+ b = Moneta::Semaphore.new(store, 'semaphore', 2)
17193
+ c = Moneta::Semaphore.new(store, 'semaphore', 2)
17194
+ a.synchronize do
17195
+ a.locked?.should be_true
17196
+ b.synchronize do
17197
+ b.locked?.should be_true
17198
+ c.try_lock.should be_false
17199
+ end
17200
+ end
17201
+ end
17202
+
17203
+ end
17204
+
17205
+ #################### create ####################
17206
+
17207
+ shared_examples_for 'create' do
17208
+ it 'creates the given key' do
17209
+ store.create('key','value').should be_true
17210
+ store['key'].should == 'value'
17211
+ end
17212
+
17213
+ it 'creates raw value with the given key' do
17214
+ store.raw.create('key','value').should be_true
17215
+ store.raw['key'].should == 'value'
17216
+ end
17217
+
17218
+ it 'does not create a key if it exists' do
17219
+ store['key'] = 'value'
17220
+ store.create('key','another value').should be_false
17221
+ store['key'].should == 'value'
17222
+ end
17223
+
17224
+ it 'supports Mutex' do
17225
+ a = Moneta::Mutex.new(store, 'mutex')
17226
+ b = Moneta::Mutex.new(store, 'mutex')
17227
+ a.lock.should be_true
17228
+ b.try_lock.should be_false
17229
+ a.unlock.should be_nil
17230
+ end
17231
+
17232
+ end
17233
+
17234
+ #################### not_create ####################
17235
+
17236
+ shared_examples_for 'not_create' do
17237
+ it 'does not support #create' do
17238
+ expect do
17239
+ store.create('key','value')
17240
+ end.to raise_error(NotImplementedError)
17241
+ end
17242
+ end
17243
+
17244
+ #################### create_expires ####################
17245
+
17246
+ shared_examples_for 'create_expires' do
17247
+ it 'creates the given key and expires it' do
17248
+ store.create('key','value', :expires => 1).should be_true
17249
+ store['key'].should == 'value'
17250
+ sleep 2
17251
+ store.key?('key').should be_false
17252
+ end
17253
+
17254
+ it 'does not change expires if the key exists' do
17255
+ store.store('key', 'value', :expires => false).should == 'value'
17256
+ store.create('key','another value', :expires => 1).should be_false
17257
+ store['key'].should == 'value'
17258
+ sleep 2
17259
+ store['key'].should == 'value'
17260
+ store.key?('key').should be_true
17261
+ end
17189
17262
  end
17190
17263
 
17191
17264
  #################### marshallable_key ####################
@@ -17291,9 +17364,9 @@ shared_examples_for 'transform_value' do
17291
17364
  end
17292
17365
  end
17293
17366
 
17294
- #################### transform_value_with_expires ####################
17367
+ #################### transform_value_expires ####################
17295
17368
 
17296
- shared_examples_for 'transform_value_with_expires' do
17369
+ shared_examples_for 'transform_value_expires' do
17297
17370
  it 'allows to bypass transformer with :raw' do
17298
17371
  store['key'] = 'value'
17299
17372
  load_value(store.load('key', :raw => true)).should == 'value'
@@ -43,7 +43,7 @@ describe Rack::MonetaCookies do
43
43
  get 'key' => 'value' do
44
44
  @store.delete('key')
45
45
  end
46
- expect( @response['Set-Cookie'] ).to eql('key=; expires=Thu, 01-Jan-1970 00:00:00 GMT')
46
+ expect( @response['Set-Cookie'] ).to eql('key=; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000')
47
47
  end
48
48
 
49
49
  it 'should accept a config block' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moneta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-01-17 00:00:00.000000000 Z
14
+ date: 2013-01-24 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: A unified interface to key/value stores
17
17
  email:
@@ -80,10 +80,13 @@ files:
80
80
  - lib/moneta/server.rb
81
81
  - lib/moneta/shared.rb
82
82
  - lib/moneta/stack.rb
83
+ - lib/moneta/synchronize.rb
83
84
  - lib/moneta/transformer.rb
84
85
  - lib/moneta/transformer/config.rb
85
86
  - lib/moneta/transformer/helper.rb
87
+ - lib/moneta/utils.rb
86
88
  - lib/moneta/version.rb
89
+ - lib/moneta/weak.rb
87
90
  - lib/moneta/wrapper.rb
88
91
  - lib/rack/cache/moneta.rb
89
92
  - lib/rack/moneta_cookies.rb
@@ -144,12 +147,15 @@ files:
144
147
  - spec/moneta/expires_memory_spec.rb
145
148
  - spec/moneta/expires_memory_with_default_expires_spec.rb
146
149
  - spec/moneta/lock_spec.rb
150
+ - spec/moneta/mutex_spec.rb
147
151
  - spec/moneta/null_adapter_spec.rb
148
152
  - spec/moneta/optionmerger_spec.rb
149
153
  - spec/moneta/pool_spec.rb
150
154
  - spec/moneta/proxy_expires_memory_spec.rb
151
155
  - spec/moneta/proxy_redis_spec.rb
152
- - spec/moneta/shared_spec.rb
156
+ - spec/moneta/semaphore_spec.rb
157
+ - spec/moneta/shared_tcp_spec.rb
158
+ - spec/moneta/shared_unix_spec.rb
153
159
  - spec/moneta/simple_activerecord_spec.rb
154
160
  - spec/moneta/simple_activerecord_with_expires_spec.rb
155
161
  - spec/moneta/simple_cassandra_spec.rb
@@ -218,6 +224,7 @@ files:
218
224
  - spec/moneta/transformer_bson_spec.rb
219
225
  - spec/moneta/transformer_bzip2_spec.rb
220
226
  - spec/moneta/transformer_json_spec.rb
227
+ - spec/moneta/transformer_key_inspect_spec.rb
221
228
  - spec/moneta/transformer_key_marshal_spec.rb
222
229
  - spec/moneta/transformer_key_to_s_spec.rb
223
230
  - spec/moneta/transformer_key_yaml_spec.rb
@@ -246,6 +253,8 @@ files:
246
253
  - spec/moneta/transformer_value_yaml_spec.rb
247
254
  - spec/moneta/transformer_yaml_spec.rb
248
255
  - spec/moneta/transformer_zlib_spec.rb
256
+ - spec/moneta/weak_create_spec.rb
257
+ - spec/moneta/weak_increment_spec.rb
249
258
  - spec/monetaspecs.rb
250
259
  - spec/rack/cache_moneta_spec.rb
251
260
  - spec/rack/moneta_cookies_spec.rb
@@ -324,12 +333,15 @@ test_files:
324
333
  - spec/moneta/expires_memory_spec.rb
325
334
  - spec/moneta/expires_memory_with_default_expires_spec.rb
326
335
  - spec/moneta/lock_spec.rb
336
+ - spec/moneta/mutex_spec.rb
327
337
  - spec/moneta/null_adapter_spec.rb
328
338
  - spec/moneta/optionmerger_spec.rb
329
339
  - spec/moneta/pool_spec.rb
330
340
  - spec/moneta/proxy_expires_memory_spec.rb
331
341
  - spec/moneta/proxy_redis_spec.rb
332
- - spec/moneta/shared_spec.rb
342
+ - spec/moneta/semaphore_spec.rb
343
+ - spec/moneta/shared_tcp_spec.rb
344
+ - spec/moneta/shared_unix_spec.rb
333
345
  - spec/moneta/simple_activerecord_spec.rb
334
346
  - spec/moneta/simple_activerecord_with_expires_spec.rb
335
347
  - spec/moneta/simple_cassandra_spec.rb
@@ -398,6 +410,7 @@ test_files:
398
410
  - spec/moneta/transformer_bson_spec.rb
399
411
  - spec/moneta/transformer_bzip2_spec.rb
400
412
  - spec/moneta/transformer_json_spec.rb
413
+ - spec/moneta/transformer_key_inspect_spec.rb
401
414
  - spec/moneta/transformer_key_marshal_spec.rb
402
415
  - spec/moneta/transformer_key_to_s_spec.rb
403
416
  - spec/moneta/transformer_key_yaml_spec.rb
@@ -426,8 +439,11 @@ test_files:
426
439
  - spec/moneta/transformer_value_yaml_spec.rb
427
440
  - spec/moneta/transformer_yaml_spec.rb
428
441
  - spec/moneta/transformer_zlib_spec.rb
442
+ - spec/moneta/weak_create_spec.rb
443
+ - spec/moneta/weak_increment_spec.rb
429
444
  - spec/monetaspecs.rb
430
445
  - spec/rack/cache_moneta_spec.rb
431
446
  - spec/rack/moneta_cookies_spec.rb
432
447
  - spec/rack/moneta_store_spec.rb
433
448
  - spec/rack/session_moneta_spec.rb
449
+ has_rdoc: