moneta 0.7.20 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -5
- data/CHANGES +6 -0
- data/CONTRIBUTORS +2 -0
- data/Gemfile +31 -44
- data/LICENSE +1 -1
- data/README.md +82 -59
- data/lib/active_support/cache/moneta_store.rb +3 -3
- data/lib/moneta.rb +4 -2
- data/lib/moneta/adapters/activerecord.rb +8 -8
- data/lib/moneta/adapters/cassandra.rb +8 -8
- data/lib/moneta/adapters/couch.rb +1 -1
- data/lib/moneta/adapters/datamapper.rb +5 -5
- data/lib/moneta/adapters/daybreak.rb +1 -1
- data/lib/moneta/adapters/fog.rb +2 -2
- data/lib/moneta/adapters/lmdb.rb +1 -1
- data/lib/moneta/adapters/localmemcache.rb +1 -1
- data/lib/moneta/adapters/memcached/dalli.rb +3 -3
- data/lib/moneta/adapters/memcached/native.rb +1 -1
- data/lib/moneta/adapters/mongo.rb +6 -164
- data/lib/moneta/adapters/mongo/base.rb +63 -0
- data/lib/moneta/adapters/mongo/moped.rb +113 -0
- data/lib/moneta/adapters/mongo/official.rb +121 -0
- data/lib/moneta/adapters/pstore.rb +1 -5
- data/lib/moneta/adapters/restclient.rb +1 -1
- data/lib/moneta/adapters/sequel.rb +10 -10
- data/lib/moneta/cache.rb +1 -1
- data/lib/moneta/logger.rb +2 -2
- data/lib/moneta/mixins.rb +4 -4
- data/lib/moneta/shared.rb +2 -2
- data/lib/moneta/stack.rb +2 -2
- data/lib/moneta/synchronize.rb +2 -2
- data/lib/moneta/transformer.rb +5 -5
- data/lib/moneta/transformer/config.rb +38 -40
- data/lib/moneta/version.rb +1 -1
- data/lib/rack/cache/moneta.rb +1 -1
- data/lib/rack/moneta_cookies.rb +2 -2
- data/lib/rack/moneta_rest.rb +1 -1
- data/lib/rack/moneta_store.rb +4 -4
- data/lib/rack/session/moneta.rb +14 -2
- data/moneta.gemspec +1 -0
- data/script/benchmarks +97 -96
- data/script/generate-specs +763 -730
- data/script/install-bundle +1 -1
- data/script/install-kyotocabinet +2 -2
- data/script/memusage +1 -1
- data/script/upload-bundle +1 -1
- data/spec/action_dispatch/session_moneta_store_spec.rb +5 -5
- data/spec/active_support/cache_moneta_store_spec.rb +20 -20
- data/spec/moneta/adapter_activerecord_exisiting_connection_spec.rb +2 -2
- data/spec/moneta/adapter_activerecord_spec.rb +6 -6
- data/spec/moneta/adapter_cassandra_spec.rb +1 -1
- data/spec/moneta/adapter_cassandra_with_default_expires_spec.rb +1 -1
- data/spec/moneta/adapter_couch_spec.rb +1 -1
- data/spec/moneta/adapter_datamapper_spec.rb +6 -6
- data/spec/moneta/adapter_daybreak_spec.rb +1 -1
- 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 +4 -4
- data/spec/moneta/adapter_gdbm_spec.rb +1 -1
- data/spec/moneta/adapter_hbase_spec.rb +1 -1
- data/spec/moneta/adapter_kyotocabinet_spec.rb +1 -1
- data/spec/moneta/adapter_leveldb_spec.rb +1 -1
- data/spec/moneta/adapter_lmdb_spec.rb +1 -1
- data/spec/moneta/adapter_lmdb_with_db_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 -1
- data/spec/moneta/adapter_memcached_dalli_with_default_expires_spec.rb +1 -1
- data/spec/moneta/adapter_memcached_native_spec.rb +1 -1
- data/spec/moneta/adapter_memcached_native_with_default_expires_spec.rb +1 -1
- data/spec/moneta/adapter_memcached_spec.rb +1 -1
- data/spec/moneta/adapter_memcached_with_default_expires_spec.rb +1 -1
- data/spec/moneta/adapter_mongo_moped_spec.rb +56 -0
- data/spec/moneta/adapter_mongo_moped_with_default_expires_spec.rb +51 -0
- data/spec/moneta/adapter_mongo_official_spec.rb +56 -0
- data/spec/moneta/adapter_mongo_official_with_default_expires_spec.rb +51 -0
- data/spec/moneta/adapter_mongo_spec.rb +1 -7
- data/spec/moneta/adapter_mongo_with_default_expires_spec.rb +1 -1
- data/spec/moneta/adapter_pstore_spec.rb +1 -1
- data/spec/moneta/adapter_redis_with_default_expires_spec.rb +1 -1
- data/spec/moneta/adapter_restclient_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 +1 -1
- 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/expires_file_spec.rb +3 -3
- data/spec/moneta/expires_memory_with_default_expires_spec.rb +1 -1
- data/spec/moneta/mutex_spec.rb +1 -1
- data/spec/moneta/optionmerger_spec.rb +26 -26
- data/spec/moneta/pool_spec.rb +1 -1
- data/spec/moneta/semaphore_spec.rb +1 -1
- data/spec/moneta/shared_tcp_spec.rb +2 -2
- data/spec/moneta/shared_unix_spec.rb +2 -2
- data/spec/moneta/stack_file_memory_spec.rb +1 -1
- data/spec/moneta/stack_memory_file_spec.rb +1 -1
- data/spec/moneta/standard_activerecord_spec.rb +1 -1
- data/spec/moneta/standard_activerecord_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_cassandra_spec.rb +1 -1
- data/spec/moneta/standard_client_tcp_spec.rb +1 -1
- data/spec/moneta/standard_client_unix_spec.rb +2 -2
- data/spec/moneta/standard_couch_spec.rb +1 -1
- data/spec/moneta/standard_couch_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_datamapper_spec.rb +2 -2
- data/spec/moneta/standard_datamapper_with_expires_spec.rb +2 -2
- data/spec/moneta/standard_datamapper_with_repository_spec.rb +2 -2
- data/spec/moneta/standard_daybreak_spec.rb +1 -1
- data/spec/moneta/standard_daybreak_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_dbm_spec.rb +1 -1
- data/spec/moneta/standard_dbm_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_file_spec.rb +1 -1
- data/spec/moneta/standard_file_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_fog_spec.rb +4 -4
- data/spec/moneta/standard_fog_with_expires_spec.rb +5 -5
- data/spec/moneta/standard_gdbm_spec.rb +1 -1
- data/spec/moneta/standard_gdbm_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_hashfile_spec.rb +1 -1
- data/spec/moneta/standard_hashfile_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_hbase_spec.rb +1 -1
- data/spec/moneta/standard_hbase_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_kyotocabinet_spec.rb +1 -1
- data/spec/moneta/standard_kyotocabinet_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_leveldb_spec.rb +1 -1
- data/spec/moneta/standard_leveldb_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_lmdb_spec.rb +1 -1
- data/spec/moneta/standard_lmdb_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_localmemcache_spec.rb +1 -1
- data/spec/moneta/standard_localmemcache_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_lruhash_spec.rb +1 -1
- data/spec/moneta/standard_lruhash_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_memcached_dalli_spec.rb +1 -1
- data/spec/moneta/standard_memcached_native_spec.rb +1 -1
- data/spec/moneta/standard_memcached_spec.rb +1 -1
- data/spec/moneta/standard_memory_spec.rb +1 -1
- data/spec/moneta/standard_memory_with_compress_spec.rb +1 -1
- data/spec/moneta/standard_memory_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_memory_with_json_key_serializer_spec.rb +1 -1
- data/spec/moneta/standard_memory_with_json_serializer_spec.rb +1 -1
- data/spec/moneta/standard_memory_with_json_value_serializer_spec.rb +1 -1
- data/spec/moneta/standard_memory_with_prefix_spec.rb +1 -1
- data/spec/moneta/standard_memory_with_snappy_compress_spec.rb +1 -1
- data/spec/moneta/standard_mongo_moped_spec.rb +255 -0
- data/spec/moneta/standard_mongo_official_spec.rb +255 -0
- data/spec/moneta/standard_mongo_spec.rb +1 -1
- data/spec/moneta/standard_null_spec.rb +1 -1
- data/spec/moneta/standard_pstore_spec.rb +1 -1
- data/spec/moneta/standard_pstore_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_redis_spec.rb +1 -1
- data/spec/moneta/standard_restclient_spec.rb +1 -1
- data/spec/moneta/standard_riak_spec.rb +1 -1
- data/spec/moneta/standard_riak_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_sdbm_spec.rb +1 -1
- data/spec/moneta/standard_sdbm_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_sequel_spec.rb +1 -1
- data/spec/moneta/standard_sequel_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_sqlite_spec.rb +1 -1
- data/spec/moneta/standard_sqlite_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_tdb_spec.rb +1 -1
- data/spec/moneta/standard_tdb_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_tokyocabinet_spec.rb +1 -1
- data/spec/moneta/standard_tokyocabinet_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_tokyotyrant_spec.rb +1 -1
- data/spec/moneta/standard_tokyotyrant_with_expires_spec.rb +1 -1
- data/spec/moneta/standard_yaml_spec.rb +1 -1
- data/spec/moneta/standard_yaml_with_expires_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_inspect_spec.rb +1 -1
- data/spec/moneta/transformer_key_marshal_spec.rb +1 -1
- data/spec/moneta/transformer_key_to_s_spec.rb +1 -1
- data/spec/moneta/transformer_key_yaml_spec.rb +1 -1
- data/spec/moneta/transformer_lz4_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_city128_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_city32_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_city64_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_escape_spec.rb +1 -1
- data/spec/moneta/transformer_marshal_hex_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_qp_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_php_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/moneta/weak_create_spec.rb +4 -4
- data/spec/moneta/weak_increment_spec.rb +4 -4
- data/spec/monetaspecs.rb +481 -481
- metadata +14 -185
|
@@ -2,47 +2,45 @@ module Moneta
|
|
|
2
2
|
class Transformer
|
|
3
3
|
# Available key/value transformers
|
|
4
4
|
TRANSFORMER = {
|
|
5
|
-
# Name
|
|
6
|
-
:
|
|
7
|
-
:
|
|
8
|
-
:
|
|
9
|
-
:
|
|
10
|
-
:
|
|
11
|
-
:
|
|
12
|
-
:
|
|
13
|
-
:
|
|
14
|
-
:
|
|
15
|
-
:
|
|
16
|
-
:
|
|
17
|
-
:
|
|
18
|
-
:
|
|
19
|
-
:
|
|
20
|
-
:
|
|
21
|
-
:
|
|
22
|
-
:
|
|
23
|
-
:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
:
|
|
27
|
-
:
|
|
28
|
-
:
|
|
29
|
-
:uuencode => [ :encode, "%s.unpack('u').first", "[%s].pack('u')" ],
|
|
30
|
-
:hmac => [ :hmac, 'Helper.hmacverify(%s, options[:secret] || @secret)',
|
|
5
|
+
# Name: [ Type, Load, Dump, Library ],
|
|
6
|
+
bencode: [ :serialize, '::BEncode.load(%s)', '::BEncode.dump(%s)', 'bencode' ],
|
|
7
|
+
bert: [ :serialize, '::BERT.decode(%s)', '::BERT.encode(%s)', 'bert' ],
|
|
8
|
+
bson: [ :serialize, "::BSON.deserialize(%s)['v']", "::BSON.serialize('v'=>%s).to_s", 'bson' ],
|
|
9
|
+
json: [ :serialize, '::MultiJson.load(%s)', '::MultiJson.dump(%s)', 'multi_json' ],
|
|
10
|
+
marshal: [ :serialize, '::Marshal.load(%s)', '::Marshal.dump(%s)' ],
|
|
11
|
+
msgpack: [ :serialize, '::MessagePack.unpack(%s)', '::MessagePack.pack(%s)', 'msgpack' ],
|
|
12
|
+
ox: [ :serialize, '::Ox.parse_obj(%s)', '::Ox.dump(%s)', 'ox' ],
|
|
13
|
+
php: [ :serialize, '::PHP.unserialize(%s)', '::PHP.serialize(%s)', 'php_serialize' ],
|
|
14
|
+
tnet: [ :serialize, '::TNetstring.parse(%s).first', '::TNetstring.dump(%s)', 'tnetstring' ],
|
|
15
|
+
yaml: [ :serialize, '::YAML.load(%s)', '::YAML.dump(%s)', 'yaml' ],
|
|
16
|
+
bzip2: [ :compress, '::Bzip2.uncompress(%s)', '::Bzip2.compress(%s)', 'bzip2' ],
|
|
17
|
+
lz4: [ :compress, '::LZ4.uncompress(%s)', '::LZ4.compress(%s)', 'lz4-ruby' ],
|
|
18
|
+
lzma: [ :compress, '::LZMA.decompress(%s)', '::LZMA.compress(%s)', 'lzma' ],
|
|
19
|
+
lzo: [ :compress, '::LZO.decompress(%s)', '::LZO.compress(%s)', 'lzoruby' ],
|
|
20
|
+
snappy: [ :compress, '::Snappy.inflate(%s)', '::Snappy.deflate(%s)', 'snappy' ],
|
|
21
|
+
quicklz: [ :compress, '::QuickLZ.decompress(%s)', '::QuickLZ.compress(%s)', 'qlzruby' ],
|
|
22
|
+
zlib: [ :compress, '::Zlib::Inflate.inflate(%s)', '::Zlib::Deflate.deflate(%s)', 'zlib' ],
|
|
23
|
+
base64: [ :encode, "%s.unpack('m0').first", "[%s].pack('m0')" ],
|
|
24
|
+
escape: [ :encode, 'Helper.unescape(%s)', 'Helper.escape(%s)' ],
|
|
25
|
+
hex: [ :encode, "[%s].pack('H*')", "%s.unpack('H*').first" ],
|
|
26
|
+
qp: [ :encode, "%s.unpack('M').first", "[%s].pack('M')" ],
|
|
27
|
+
uuencode: [ :encode, "%s.unpack('u').first", "[%s].pack('u')" ],
|
|
28
|
+
hmac: [ :hmac, 'Helper.hmacverify(%s, options[:secret] || @secret)',
|
|
31
29
|
'Helper.hmacsign(%s, options[:secret] || @secret)', 'openssl' ],
|
|
32
|
-
:
|
|
33
|
-
:
|
|
34
|
-
:
|
|
35
|
-
:
|
|
36
|
-
:
|
|
37
|
-
:
|
|
38
|
-
:
|
|
39
|
-
:
|
|
40
|
-
:
|
|
41
|
-
:
|
|
42
|
-
:
|
|
43
|
-
:
|
|
44
|
-
:
|
|
45
|
-
:
|
|
30
|
+
truncate: [ :truncate, nil, 'Helper.truncate(%s, @maxlen)', 'digest/md5' ],
|
|
31
|
+
md5: [ :digest, nil, '::Digest::MD5.hexdigest(%s)', 'digest/md5' ],
|
|
32
|
+
rmd160: [ :digest, nil, '::Digest::RMD160.hexdigest(%s)', 'digest/rmd160' ],
|
|
33
|
+
sha1: [ :digest, nil, '::Digest::SHA1.hexdigest(%s)', 'digest/sha1' ],
|
|
34
|
+
sha256: [ :digest, nil, '::Digest::SHA256.hexdigest(%s)', 'digest/sha2' ],
|
|
35
|
+
sha384: [ :digest, nil, '::Digest::SHA384.hexdigest(%s)', 'digest/sha2' ],
|
|
36
|
+
sha512: [ :digest, nil, '::Digest::SHA512.hexdigest(%s)', 'digest/sha2' ],
|
|
37
|
+
city32: [ :digest, nil, '::CityHash.hash32(%s).to_s(16)', 'cityhash' ],
|
|
38
|
+
city64: [ :digest, nil, '::CityHash.hash64(%s).to_s(16)', 'cityhash' ],
|
|
39
|
+
city128: [ :digest, nil, '::CityHash.hash128(%s).to_s(16)', 'cityhash' ],
|
|
40
|
+
prefix: [ :prefix, nil, '(options[:prefix] || @prefix)+%s' ],
|
|
41
|
+
spread: [ :spread, nil, 'Helper.spread(%s)' ],
|
|
42
|
+
to_s: [ :string, nil, '%s.to_s' ],
|
|
43
|
+
inspect: [ :string, nil, '%s.inspect' ],
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
# Allowed value transformers (Read it like a regular expression!)
|
data/lib/moneta/version.rb
CHANGED
data/lib/rack/cache/moneta.rb
CHANGED
|
@@ -82,7 +82,7 @@ module Rack
|
|
|
82
82
|
def write(body, ttl = 0)
|
|
83
83
|
buf = StringIO.new
|
|
84
84
|
key, size = slurp(body) { |part| buf.write(part) }
|
|
85
|
-
@cache.store(key, buf.string, ttl == 0 ? {} : {:
|
|
85
|
+
@cache.store(key, buf.string, ttl == 0 ? {} : {expires: ttl})
|
|
86
86
|
[key, size]
|
|
87
87
|
end
|
|
88
88
|
|
data/lib/rack/moneta_cookies.rb
CHANGED
|
@@ -14,12 +14,12 @@ module Rack
|
|
|
14
14
|
#
|
|
15
15
|
# @example config.ru
|
|
16
16
|
# # Give it some options
|
|
17
|
-
# use Rack::MonetaCookies, :
|
|
17
|
+
# use Rack::MonetaCookies, domain: 'example.com', path: '/path'
|
|
18
18
|
#
|
|
19
19
|
# @example config.ru
|
|
20
20
|
# # Pass it a block like the one passed to Moneta.build
|
|
21
21
|
# use Rack::MonetaCookies do
|
|
22
|
-
# use :Transformer, :
|
|
22
|
+
# use :Transformer, key: :prefix, prefix: 'moneta.'
|
|
23
23
|
# adapter :Cookie
|
|
24
24
|
# end
|
|
25
25
|
#
|
data/lib/rack/moneta_rest.rb
CHANGED
data/lib/rack/moneta_store.rb
CHANGED
|
@@ -2,11 +2,11 @@ require 'moneta'
|
|
|
2
2
|
|
|
3
3
|
module Rack
|
|
4
4
|
# A Rack middleware that inserts a Moneta store in the environment
|
|
5
|
-
# and supports per-request caching via the the option
|
|
5
|
+
# and supports per-request caching via the the option `cache: true`.
|
|
6
6
|
#
|
|
7
7
|
# @example config.ru
|
|
8
8
|
# # Add Rack::MonetaStore somewhere in your rack stack
|
|
9
|
-
# use Rack::MonetaStore, :Memory, :
|
|
9
|
+
# use Rack::MonetaStore, :Memory, cache: true
|
|
10
10
|
#
|
|
11
11
|
# run lambda { |env|
|
|
12
12
|
# env['rack.moneta_store'] # is a Moneta store with per-request caching
|
|
@@ -15,7 +15,7 @@ module Rack
|
|
|
15
15
|
# @example config.ru
|
|
16
16
|
# # Pass it a block like the one passed to Moneta.build
|
|
17
17
|
# use Rack::MonetaStore do
|
|
18
|
-
# use :Transformer, :
|
|
18
|
+
# use :Transformer, value: :zlib
|
|
19
19
|
# adapter :Cookie
|
|
20
20
|
# end
|
|
21
21
|
#
|
|
@@ -38,7 +38,7 @@ module Rack
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def call(env)
|
|
41
|
-
env['rack.moneta_store'] = @cache ? ::Moneta::Cache.new(:
|
|
41
|
+
env['rack.moneta_store'] = @cache ? ::Moneta::Cache.new(cache: ::Moneta::Adapters::Memory.new, adapter: @store) : @store
|
|
42
42
|
@app.call(env)
|
|
43
43
|
end
|
|
44
44
|
end
|
data/lib/rack/session/moneta.rb
CHANGED
|
@@ -4,6 +4,18 @@ require 'thread'
|
|
|
4
4
|
|
|
5
5
|
module Rack
|
|
6
6
|
module Session
|
|
7
|
+
# Rack::Session::Moneta stores sessions in a Moneta store.
|
|
8
|
+
#
|
|
9
|
+
# Example:
|
|
10
|
+
#
|
|
11
|
+
# use Rack::Session::Moneta, key: 'rack.session',
|
|
12
|
+
# domain: 'foo.com',
|
|
13
|
+
# path: '/',
|
|
14
|
+
# expire_after: 2592000,
|
|
15
|
+
# store: Moneta.new(...)
|
|
16
|
+
#
|
|
17
|
+
# You can use all options supported by `Rack::Session::Abstract::ID`.
|
|
18
|
+
#
|
|
7
19
|
# @api public
|
|
8
20
|
class Moneta < Abstract::ID
|
|
9
21
|
attr_reader :mutex, :pool
|
|
@@ -15,7 +27,7 @@ module Rack
|
|
|
15
27
|
@pool = ::Moneta.build(&block)
|
|
16
28
|
else
|
|
17
29
|
raise ArgumentError, 'Block or option :store is required' unless @pool = options[:store]
|
|
18
|
-
@pool = ::Moneta.new(@pool, :
|
|
30
|
+
@pool = ::Moneta.new(@pool, expires: true) if Symbol === @pool
|
|
19
31
|
end
|
|
20
32
|
@pool = ::Moneta::WeakCreate.new(@pool) unless @pool.supports?(:create)
|
|
21
33
|
@mutex = ::Mutex.new
|
|
@@ -43,7 +55,7 @@ module Rack
|
|
|
43
55
|
def set_session(env, session_id, new_session, options)
|
|
44
56
|
with_lock(env) do
|
|
45
57
|
@pool.store(session_id, new_session,
|
|
46
|
-
options[:expire_after] ? { :
|
|
58
|
+
options[:expire_after] ? { expires: options[:expire_after] } : {})
|
|
47
59
|
session_id
|
|
48
60
|
end
|
|
49
61
|
end
|
data/moneta.gemspec
CHANGED
data/script/benchmarks
CHANGED
|
@@ -31,103 +31,104 @@ class MonetaBenchmarks
|
|
|
31
31
|
|
|
32
32
|
STORES = {
|
|
33
33
|
# SDBM accepts only very short key/value pairs (1k for both)
|
|
34
|
-
# :
|
|
34
|
+
# SDBM: { file: "#{DIR}/sdbm" },
|
|
35
35
|
# YAML is too slow
|
|
36
|
-
# :
|
|
37
|
-
:
|
|
38
|
-
:
|
|
39
|
-
:
|
|
40
|
-
:
|
|
41
|
-
:
|
|
42
|
-
:
|
|
43
|
-
:
|
|
44
|
-
:
|
|
45
|
-
:
|
|
46
|
-
:
|
|
47
|
-
:
|
|
48
|
-
:
|
|
49
|
-
:
|
|
50
|
-
:
|
|
51
|
-
:
|
|
52
|
-
:
|
|
53
|
-
:
|
|
54
|
-
:
|
|
55
|
-
:
|
|
56
|
-
:
|
|
57
|
-
:
|
|
58
|
-
:
|
|
59
|
-
:
|
|
60
|
-
:
|
|
61
|
-
:
|
|
62
|
-
|
|
36
|
+
# YAML: { file: "#{DIR}/yaml" },
|
|
37
|
+
ActiveRecord: { table: 'activerecord', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), username: 'root', database: 'moneta' } },
|
|
38
|
+
Cassandra: {},
|
|
39
|
+
Client: {},
|
|
40
|
+
Couch: {},
|
|
41
|
+
DBM: { file: "#{DIR}/dbm" },
|
|
42
|
+
DataMapper: { setup: 'mysql://root:@localhost/moneta', table: 'datamapper' },
|
|
43
|
+
Daybreak: { file: "#{DIR}/daybreak" },
|
|
44
|
+
File: { dir: "#{DIR}/file" },
|
|
45
|
+
GDBM: { file: "#{DIR}/gdbm" },
|
|
46
|
+
HBase: {},
|
|
47
|
+
HashFile: { dir: "#{DIR}/hashfile" },
|
|
48
|
+
KyotoCabinet: { file: "#{DIR}/kyotocabinet.kch" },
|
|
49
|
+
LRUHash: {},
|
|
50
|
+
LevelDB: { dir: "#{DIR}/leveldb" },
|
|
51
|
+
LocalMemCache: { file: "#{DIR}/lmc" },
|
|
52
|
+
LMDB: { dir: "#{DIR}/lmdb" },
|
|
53
|
+
MemcachedDalli: {},
|
|
54
|
+
MemcachedNative: {},
|
|
55
|
+
Memory: {},
|
|
56
|
+
MongoMoped: {},
|
|
57
|
+
MongoOfficial: {},
|
|
58
|
+
PStore: { file: "#{DIR}/pstore" },
|
|
59
|
+
Redis: {},
|
|
60
|
+
RestClient: { url: 'http://localhost:8808/' },
|
|
61
|
+
Riak: {},
|
|
62
|
+
Sequel: { table: 'sequel',
|
|
63
|
+
db: (defined?(JRUBY_VERSION) ?
|
|
63
64
|
'jdbc:mysql://localhost/moneta?user=root' :
|
|
64
65
|
'mysql2://root:@localhost/moneta') },
|
|
65
|
-
:
|
|
66
|
-
:
|
|
67
|
-
:
|
|
68
|
-
:
|
|
66
|
+
Sqlite: { file: ':memory:' },
|
|
67
|
+
TDB: { file: "#{DIR}/tdb" },
|
|
68
|
+
TokyoCabinet: { file: "#{DIR}/tokyocabinet" },
|
|
69
|
+
TokyoTyrant: {},
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
CONFIGS = {
|
|
72
|
-
:
|
|
73
|
-
:
|
|
74
|
-
:
|
|
75
|
-
:
|
|
76
|
-
:
|
|
77
|
-
:
|
|
78
|
-
:
|
|
79
|
-
:
|
|
80
|
-
:
|
|
73
|
+
uniform_small: {
|
|
74
|
+
runs: 3,
|
|
75
|
+
keys: 1000,
|
|
76
|
+
min_key_len: 1,
|
|
77
|
+
max_key_len: 32,
|
|
78
|
+
key_dist: :uniform,
|
|
79
|
+
min_val_len: 0,
|
|
80
|
+
max_val_len: 256,
|
|
81
|
+
val_dist: :uniform
|
|
81
82
|
},
|
|
82
|
-
:
|
|
83
|
-
:
|
|
84
|
-
:
|
|
85
|
-
:
|
|
86
|
-
:
|
|
87
|
-
:
|
|
88
|
-
:
|
|
89
|
-
:
|
|
90
|
-
:
|
|
83
|
+
uniform_medium: {
|
|
84
|
+
runs: 3,
|
|
85
|
+
keys: 1000,
|
|
86
|
+
min_key_len: 3,
|
|
87
|
+
max_key_len: 128,
|
|
88
|
+
key_dist: :uniform,
|
|
89
|
+
min_val_len: 0,
|
|
90
|
+
max_val_len: 1024,
|
|
91
|
+
val_dist: :uniform
|
|
91
92
|
},
|
|
92
|
-
:
|
|
93
|
-
:
|
|
94
|
-
:
|
|
95
|
-
:
|
|
96
|
-
:
|
|
97
|
-
:
|
|
98
|
-
:
|
|
99
|
-
:
|
|
100
|
-
:
|
|
93
|
+
uniform_large: {
|
|
94
|
+
runs: 3,
|
|
95
|
+
keys: 100,
|
|
96
|
+
min_key_len: 3,
|
|
97
|
+
max_key_len: 128,
|
|
98
|
+
key_dist: :uniform,
|
|
99
|
+
min_val_len: 0,
|
|
100
|
+
max_val_len: 10240,
|
|
101
|
+
val_dist: :uniform
|
|
101
102
|
},
|
|
102
|
-
:
|
|
103
|
-
:
|
|
104
|
-
:
|
|
105
|
-
:
|
|
106
|
-
:
|
|
107
|
-
:
|
|
108
|
-
:
|
|
109
|
-
:
|
|
110
|
-
:
|
|
103
|
+
normal_small: {
|
|
104
|
+
runs: 3,
|
|
105
|
+
keys: 1000,
|
|
106
|
+
min_key_len: 1,
|
|
107
|
+
max_key_len: 32,
|
|
108
|
+
key_dist: :normal,
|
|
109
|
+
min_val_len: 0,
|
|
110
|
+
max_val_len: 256,
|
|
111
|
+
val_dist: :normal
|
|
111
112
|
},
|
|
112
|
-
:
|
|
113
|
-
:
|
|
114
|
-
:
|
|
115
|
-
:
|
|
116
|
-
:
|
|
117
|
-
:
|
|
118
|
-
:
|
|
119
|
-
:
|
|
120
|
-
:
|
|
113
|
+
normal_medium: {
|
|
114
|
+
runs: 3,
|
|
115
|
+
keys: 1000,
|
|
116
|
+
min_key_len: 3,
|
|
117
|
+
max_key_len: 128,
|
|
118
|
+
key_dist: :normal,
|
|
119
|
+
min_val_len: 0,
|
|
120
|
+
max_val_len: 1024,
|
|
121
|
+
val_dist: :normal
|
|
121
122
|
},
|
|
122
|
-
:
|
|
123
|
-
:
|
|
124
|
-
:
|
|
125
|
-
:
|
|
126
|
-
:
|
|
127
|
-
:
|
|
128
|
-
:
|
|
129
|
-
:
|
|
130
|
-
:
|
|
123
|
+
normal_large: {
|
|
124
|
+
runs: 3,
|
|
125
|
+
keys: 100,
|
|
126
|
+
min_key_len: 3,
|
|
127
|
+
max_key_len: 128,
|
|
128
|
+
key_dist: :normal,
|
|
129
|
+
min_val_len: 0,
|
|
130
|
+
max_val_len: 10240,
|
|
131
|
+
val_dist: :normal
|
|
131
132
|
},
|
|
132
133
|
}
|
|
133
134
|
|
|
@@ -206,13 +207,13 @@ class MonetaBenchmarks
|
|
|
206
207
|
def log(level, data); end
|
|
207
208
|
end
|
|
208
209
|
|
|
209
|
-
Rack::Server.start(:
|
|
210
|
+
Rack::Server.start(app: Rack::Builder.app do
|
|
210
211
|
use Rack::Lint
|
|
211
|
-
run Rack::MonetaRest.new(:
|
|
212
|
+
run Rack::MonetaRest.new(store: :Memory)
|
|
212
213
|
end,
|
|
213
|
-
:
|
|
214
|
-
:
|
|
215
|
-
:
|
|
214
|
+
environment: :none,
|
|
215
|
+
server: :webrick,
|
|
216
|
+
Port: 8808)
|
|
216
217
|
rescue Exception => ex
|
|
217
218
|
puts "\e[31mFailed to start Rack server - #{ex.message}\e[0m"
|
|
218
219
|
end
|
|
@@ -227,7 +228,7 @@ class MonetaBenchmarks
|
|
|
227
228
|
if name == :DataMapper
|
|
228
229
|
begin
|
|
229
230
|
require 'dm-core'
|
|
230
|
-
DataMapper.setup(:default, :
|
|
231
|
+
DataMapper.setup(:default, adapter: :in_memory)
|
|
231
232
|
rescue LoadError => ex
|
|
232
233
|
puts "\e[31mFailed to load DataMapper - #{ex.message}\e[0m"
|
|
233
234
|
end
|
|
@@ -298,10 +299,10 @@ class MonetaBenchmarks
|
|
|
298
299
|
store = Moneta.new(name, options.dup)
|
|
299
300
|
|
|
300
301
|
@stats[name] = {
|
|
301
|
-
:
|
|
302
|
-
:
|
|
303
|
-
:
|
|
304
|
-
:
|
|
302
|
+
write: [],
|
|
303
|
+
read: [],
|
|
304
|
+
sum: [],
|
|
305
|
+
error: []
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
%w(Rehearse Measure).each do |type|
|
data/script/generate-specs
CHANGED
|
@@ -19,43 +19,43 @@ class Specs
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def new(options)
|
|
22
|
-
Specs.new({:
|
|
22
|
+
Specs.new({specs: specs, key: key, value: value}.merge(options))
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def without_path
|
|
26
|
-
new(:
|
|
26
|
+
new(key: key - %w(path))
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def stringvalues_only
|
|
30
|
-
new(:
|
|
30
|
+
new(value: %w(string))
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def simplekeys_only
|
|
34
|
-
new(:
|
|
34
|
+
new(key: %w(string hash integer))
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def simplevalues_only
|
|
38
|
-
new(:
|
|
38
|
+
new(value: %w(string hash integer))
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def without_increment
|
|
42
|
-
new(:
|
|
42
|
+
new(specs: specs - [:increment, :concurrent_increment] + [:not_increment])
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def without_large
|
|
46
|
-
new(:
|
|
46
|
+
new(specs: specs - [:store_large])
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def without_concurrent
|
|
50
|
-
new(:
|
|
50
|
+
new(specs: specs - [:concurrent_increment, :concurrent_create])
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
def without_persist
|
|
54
|
-
new(:
|
|
54
|
+
new(specs: specs - [:persist, :multiprocess, :concurrent_increment, :concurrent_create] + [:not_persist])
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
def without_multiprocess
|
|
58
|
-
new(:
|
|
58
|
+
new(specs: specs - [:multiprocess, :concurrent_increment, :concurrent_create])
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def with_expires
|
|
@@ -66,60 +66,60 @@ class Specs
|
|
|
66
66
|
end
|
|
67
67
|
a << :create_expires if a.include?(:create)
|
|
68
68
|
a << :expires
|
|
69
|
-
new(:
|
|
69
|
+
new(specs: a)
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
def with_native_expires
|
|
73
73
|
a = specs.dup
|
|
74
74
|
a << :create_expires if a.include?(:create)
|
|
75
|
-
new(:
|
|
75
|
+
new(specs: a + [:expires])
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
def without_marshallable
|
|
79
|
-
new(:
|
|
79
|
+
new(specs: specs - [:marshallable_value, :marshallable_key])
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
def without_transform
|
|
83
|
-
new(:
|
|
83
|
+
new(specs: specs - [:marshallable_value, :marshallable_key, :transform_value])
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def returnsame
|
|
87
|
-
new(:
|
|
87
|
+
new(specs: specs - [:returndifferent] + [:returnsame])
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
def without_marshallable_key
|
|
91
|
-
new(:
|
|
91
|
+
new(specs: specs - [:marshallable_key])
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
def without_marshallable_value
|
|
95
|
-
new(:
|
|
95
|
+
new(specs: specs - [:marshallable_value])
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
def without_store
|
|
99
|
-
new(:
|
|
99
|
+
new(specs: specs - [:store, :store_large, :transform_value, :marshallable_value])
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
def with_default_expires
|
|
103
|
-
new(:
|
|
103
|
+
new(specs: specs + [:default_expires])
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
def without_create
|
|
107
|
-
new(:
|
|
107
|
+
new(specs: specs - [:create, :concurrent_create, :create_expires] + [:not_create])
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
-
ADAPTER_SPECS = Specs.new(:
|
|
112
|
-
STANDARD_SPECS = Specs.new(:
|
|
113
|
-
TRANSFORMER_SPECS = Specs.new(:
|
|
111
|
+
ADAPTER_SPECS = Specs.new(specs: [:null, :store, :returndifferent, :increment, :concurrent_increment, :concurrent_create, :persist, :multiprocess, :create, :features, :store_large], key: %w(string path), value: %w(string path))
|
|
112
|
+
STANDARD_SPECS = Specs.new(specs: [:null, :store, :returndifferent, :marshallable_key, :marshallable_value, :transform_value, :increment, :concurrent_increment, :concurrent_create, :persist, :multiprocess, :create, :features, :store_large])
|
|
113
|
+
TRANSFORMER_SPECS = Specs.new(specs: [:null, :store, :returndifferent, :transform_value, :increment, :create, :features, :store_large])
|
|
114
114
|
|
|
115
115
|
header = "# coding: binary\n# Generated by #{File.basename(__FILE__)}\n"
|
|
116
116
|
|
|
117
117
|
TESTS = {
|
|
118
118
|
'standard_client_tcp' => {
|
|
119
|
-
:
|
|
120
|
-
:
|
|
121
|
-
:
|
|
122
|
-
:
|
|
119
|
+
preamble: "start_server(Moneta::Adapters::Memory.new)\n",
|
|
120
|
+
store: :Client,
|
|
121
|
+
specs: STANDARD_SPECS,
|
|
122
|
+
tests: %{
|
|
123
123
|
it 'supports multiple clients' do
|
|
124
124
|
client = Moneta.new(:Client)
|
|
125
125
|
client['shared_key'] = 'shared_val'
|
|
@@ -137,424 +137,434 @@ end
|
|
|
137
137
|
}
|
|
138
138
|
},
|
|
139
139
|
'standard_client_unix' => {
|
|
140
|
-
:
|
|
141
|
-
:
|
|
142
|
-
:
|
|
143
|
-
:
|
|
140
|
+
preamble: "start_server(Moneta::Adapters::Memory.new, socket: File.join(make_tempdir, 'standard_client_unix'))\n",
|
|
141
|
+
store: :Client,
|
|
142
|
+
options: "socket: File.join(make_tempdir, 'standard_client_unix')",
|
|
143
|
+
specs: STANDARD_SPECS
|
|
144
144
|
},
|
|
145
145
|
'standard_restclient' => {
|
|
146
|
-
:
|
|
147
|
-
:
|
|
148
|
-
:
|
|
149
|
-
:
|
|
146
|
+
preamble: "start_restserver\n",
|
|
147
|
+
store: :RestClient,
|
|
148
|
+
options: "url: 'http://localhost:8808/moneta/'",
|
|
149
|
+
specs: STANDARD_SPECS.without_increment.without_create
|
|
150
150
|
},
|
|
151
151
|
'standard_memory' => {
|
|
152
|
-
:
|
|
153
|
-
:
|
|
152
|
+
store: :Memory,
|
|
153
|
+
specs: STANDARD_SPECS.without_persist
|
|
154
154
|
},
|
|
155
155
|
'standard_memory_with_expires' => {
|
|
156
|
-
:
|
|
157
|
-
:
|
|
158
|
-
:
|
|
156
|
+
store: :Memory,
|
|
157
|
+
options: 'expires: true',
|
|
158
|
+
specs: STANDARD_SPECS.with_expires.without_persist
|
|
159
159
|
},
|
|
160
160
|
'standard_memory_with_compress' => {
|
|
161
|
-
:
|
|
162
|
-
:
|
|
163
|
-
:
|
|
164
|
-
:
|
|
161
|
+
store: :Memory,
|
|
162
|
+
options: 'compress: true',
|
|
163
|
+
load_value: 'Marshal.load(::Zlib::Inflate.inflate(value))',
|
|
164
|
+
specs: STANDARD_SPECS.without_persist
|
|
165
165
|
},
|
|
166
166
|
'standard_memory_with_prefix' => {
|
|
167
|
-
:
|
|
168
|
-
:
|
|
169
|
-
:
|
|
167
|
+
store: :Memory,
|
|
168
|
+
options: 'prefix: "moneta"',
|
|
169
|
+
specs: STANDARD_SPECS.without_persist
|
|
170
170
|
},
|
|
171
171
|
'standard_memory_with_json_serializer' => {
|
|
172
|
-
:
|
|
173
|
-
:
|
|
174
|
-
:
|
|
175
|
-
:
|
|
172
|
+
store: :Memory,
|
|
173
|
+
options: 'serializer: :json',
|
|
174
|
+
load_value: '::MultiJson.load(value)',
|
|
175
|
+
specs: STANDARD_SPECS.without_marshallable.simplekeys_only.simplevalues_only.without_persist
|
|
176
176
|
},
|
|
177
177
|
'standard_memory_with_json_key_serializer' => {
|
|
178
|
-
:
|
|
179
|
-
:
|
|
180
|
-
:
|
|
178
|
+
store: :Memory,
|
|
179
|
+
options: 'key_serializer: :json',
|
|
180
|
+
specs: STANDARD_SPECS.without_marshallable_key.simplekeys_only.without_persist,
|
|
181
181
|
},
|
|
182
182
|
'standard_memory_with_json_value_serializer' => {
|
|
183
|
-
:
|
|
184
|
-
:
|
|
185
|
-
:
|
|
186
|
-
:
|
|
183
|
+
store: :Memory,
|
|
184
|
+
options: 'value_serializer: :json',
|
|
185
|
+
specs: STANDARD_SPECS.without_marshallable_value.simplevalues_only.without_persist,
|
|
186
|
+
load_value: '::MultiJson.load(value)'
|
|
187
187
|
},
|
|
188
188
|
'standard_memory_with_snappy_compress' => {
|
|
189
|
-
:
|
|
190
|
-
:
|
|
191
|
-
:
|
|
192
|
-
:
|
|
189
|
+
store: :Memory,
|
|
190
|
+
options: 'compress: :snappy',
|
|
191
|
+
load_value: 'Marshal.load(::Snappy.inflate(value))',
|
|
192
|
+
specs: STANDARD_SPECS.without_persist
|
|
193
193
|
},
|
|
194
194
|
'standard_lruhash' => {
|
|
195
|
-
:
|
|
196
|
-
:
|
|
195
|
+
store: :LRUHash,
|
|
196
|
+
specs: STANDARD_SPECS.without_persist
|
|
197
197
|
},
|
|
198
198
|
'standard_lruhash_with_expires' => {
|
|
199
|
-
:
|
|
200
|
-
:
|
|
201
|
-
:
|
|
199
|
+
store: :LRUHash,
|
|
200
|
+
options: 'expires: true',
|
|
201
|
+
specs: STANDARD_SPECS.with_expires.without_persist,
|
|
202
202
|
},
|
|
203
203
|
'standard_file' => {
|
|
204
|
-
:
|
|
205
|
-
:
|
|
206
|
-
:
|
|
204
|
+
store: :File,
|
|
205
|
+
options: 'dir: File.join(make_tempdir, "simple_file")',
|
|
206
|
+
specs: STANDARD_SPECS
|
|
207
207
|
},
|
|
208
208
|
'standard_file_with_expires' => {
|
|
209
|
-
:
|
|
210
|
-
:
|
|
211
|
-
:
|
|
209
|
+
store: :File,
|
|
210
|
+
options: 'dir: File.join(make_tempdir, "simple_file_with_expires"), expires: true',
|
|
211
|
+
specs: STANDARD_SPECS.with_expires
|
|
212
212
|
},
|
|
213
213
|
'standard_hashfile' => {
|
|
214
|
-
:
|
|
215
|
-
:
|
|
216
|
-
:
|
|
214
|
+
store: :HashFile,
|
|
215
|
+
options: 'dir: File.join(make_tempdir, "simple_hashfile")',
|
|
216
|
+
specs: STANDARD_SPECS
|
|
217
217
|
},
|
|
218
218
|
'standard_hashfile_with_expires' => {
|
|
219
|
-
:
|
|
220
|
-
:
|
|
221
|
-
:
|
|
219
|
+
store: :HashFile,
|
|
220
|
+
options: 'dir: File.join(make_tempdir, "simple_hashfile_with_expires"), expires: true',
|
|
221
|
+
specs: STANDARD_SPECS.with_expires
|
|
222
222
|
},
|
|
223
223
|
'standard_cassandra' => {
|
|
224
|
-
:
|
|
225
|
-
:
|
|
226
|
-
:
|
|
224
|
+
store: :Cassandra,
|
|
225
|
+
options: 'keyspace: "simple_cassandra"',
|
|
226
|
+
specs: STANDARD_SPECS.without_increment.without_create.with_native_expires,
|
|
227
227
|
},
|
|
228
228
|
'standard_hbase' => {
|
|
229
|
-
:
|
|
230
|
-
:
|
|
231
|
-
:
|
|
229
|
+
store: :HBase,
|
|
230
|
+
options: 'table: "simple_hbase"',
|
|
231
|
+
specs: STANDARD_SPECS.without_create
|
|
232
232
|
},
|
|
233
233
|
'standard_hbase_with_expires' => {
|
|
234
|
-
:
|
|
235
|
-
:
|
|
236
|
-
:
|
|
234
|
+
store: :HBase,
|
|
235
|
+
options: 'table: "simple_hbase", expires: true',
|
|
236
|
+
specs: STANDARD_SPECS.with_expires,
|
|
237
237
|
},
|
|
238
238
|
'standard_dbm' => {
|
|
239
|
-
:
|
|
240
|
-
:
|
|
241
|
-
:
|
|
239
|
+
store: :DBM,
|
|
240
|
+
options: 'file: File.join(make_tempdir, "simple_dbm")',
|
|
241
|
+
specs: STANDARD_SPECS.without_multiprocess
|
|
242
242
|
},
|
|
243
243
|
'standard_dbm_with_expires' => {
|
|
244
|
-
:
|
|
245
|
-
:
|
|
246
|
-
:
|
|
244
|
+
store: :DBM,
|
|
245
|
+
options: 'file: File.join(make_tempdir, "simple_dbm_with_expires"), expires: true',
|
|
246
|
+
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
|
247
247
|
},
|
|
248
248
|
'standard_tdb' => {
|
|
249
|
-
:
|
|
250
|
-
:
|
|
251
|
-
:
|
|
249
|
+
store: :TDB,
|
|
250
|
+
options: 'file: File.join(make_tempdir, "simple_tdb")',
|
|
251
|
+
specs: STANDARD_SPECS.without_multiprocess
|
|
252
252
|
},
|
|
253
253
|
'standard_tdb_with_expires' => {
|
|
254
|
-
:
|
|
255
|
-
:
|
|
256
|
-
:
|
|
254
|
+
store: :TDB,
|
|
255
|
+
options: 'file: File.join(make_tempdir, "simple_tdb_with_expires"), expires: true',
|
|
256
|
+
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
|
257
257
|
},
|
|
258
258
|
'standard_daybreak' => {
|
|
259
|
-
:
|
|
260
|
-
:
|
|
261
|
-
:
|
|
259
|
+
store: :Daybreak,
|
|
260
|
+
options: 'file: File.join(make_tempdir, "simple_daybreak")',
|
|
261
|
+
specs: STANDARD_SPECS.without_multiprocess
|
|
262
262
|
},
|
|
263
263
|
'standard_daybreak_with_expires' => {
|
|
264
|
-
:
|
|
265
|
-
:
|
|
266
|
-
:
|
|
264
|
+
store: :Daybreak,
|
|
265
|
+
options: 'file: File.join(make_tempdir, "simple_daybreak_with_expires"), expires: true',
|
|
266
|
+
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
|
267
267
|
},
|
|
268
268
|
'standard_gdbm' => {
|
|
269
|
-
:
|
|
270
|
-
:
|
|
271
|
-
:
|
|
269
|
+
store: :GDBM,
|
|
270
|
+
options: 'file: File.join(make_tempdir, "simple_gdbm")',
|
|
271
|
+
specs: STANDARD_SPECS.without_multiprocess
|
|
272
272
|
},
|
|
273
273
|
'standard_gdbm_with_expires' => {
|
|
274
|
-
:
|
|
275
|
-
:
|
|
276
|
-
:
|
|
274
|
+
store: :GDBM,
|
|
275
|
+
options: 'file: File.join(make_tempdir, "simple_gdbm_with_expires"), expires: true',
|
|
276
|
+
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
|
277
277
|
},
|
|
278
278
|
'standard_sdbm' => {
|
|
279
|
-
:
|
|
280
|
-
:
|
|
281
|
-
:
|
|
279
|
+
store: :SDBM,
|
|
280
|
+
options: 'file: File.join(make_tempdir, "simple_sdbm")',
|
|
281
|
+
specs: STANDARD_SPECS.without_multiprocess.without_large
|
|
282
282
|
},
|
|
283
283
|
'standard_sdbm_with_expires' => {
|
|
284
|
-
:
|
|
285
|
-
:
|
|
286
|
-
:
|
|
284
|
+
store: :SDBM,
|
|
285
|
+
options: 'file: File.join(make_tempdir, "simple_sdbm_with_expires"), expires: true',
|
|
286
|
+
specs: STANDARD_SPECS.without_multiprocess.with_expires.without_large
|
|
287
287
|
},
|
|
288
288
|
'standard_leveldb' => {
|
|
289
|
-
:
|
|
290
|
-
:
|
|
291
|
-
:
|
|
289
|
+
store: :LevelDB,
|
|
290
|
+
options: 'dir: File.join(make_tempdir, "simple_leveldb")',
|
|
291
|
+
specs: STANDARD_SPECS.without_multiprocess
|
|
292
292
|
},
|
|
293
293
|
'standard_leveldb_with_expires' => {
|
|
294
|
-
:
|
|
295
|
-
:
|
|
296
|
-
:
|
|
294
|
+
store: :LevelDB,
|
|
295
|
+
options: 'dir: File.join(make_tempdir, "simple_leveldb_with_expires"), expires: true',
|
|
296
|
+
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
|
297
297
|
},
|
|
298
298
|
'standard_lmdb' => {
|
|
299
|
-
:
|
|
300
|
-
:
|
|
301
|
-
:
|
|
299
|
+
store: :LMDB,
|
|
300
|
+
options: 'dir: File.join(make_tempdir, "simple_lmdb")',
|
|
301
|
+
specs: STANDARD_SPECS.without_concurrent
|
|
302
302
|
},
|
|
303
303
|
'standard_lmdb_with_expires' => {
|
|
304
|
-
:
|
|
305
|
-
:
|
|
306
|
-
:
|
|
304
|
+
store: :LMDB,
|
|
305
|
+
options: 'dir: File.join(make_tempdir, "simple_lmdb_with_expires"), expires: true',
|
|
306
|
+
specs: STANDARD_SPECS.without_concurrent.with_expires
|
|
307
307
|
},
|
|
308
308
|
'standard_pstore' => {
|
|
309
|
-
:
|
|
310
|
-
:
|
|
311
|
-
:
|
|
312
|
-
:
|
|
309
|
+
store: :PStore,
|
|
310
|
+
options: 'file: File.join(make_tempdir, "simple_pstore")',
|
|
311
|
+
load_value: 'value',
|
|
312
|
+
specs: STANDARD_SPECS
|
|
313
313
|
},
|
|
314
314
|
'standard_pstore_with_expires' => {
|
|
315
|
-
:
|
|
316
|
-
:
|
|
317
|
-
:
|
|
318
|
-
:
|
|
315
|
+
store: :PStore,
|
|
316
|
+
options: 'file: File.join(make_tempdir, "simple_pstore_with_expires"), expires: true',
|
|
317
|
+
load_value: 'value',
|
|
318
|
+
specs: STANDARD_SPECS.with_expires
|
|
319
319
|
},
|
|
320
320
|
'standard_yaml' => {
|
|
321
|
-
:
|
|
322
|
-
:
|
|
323
|
-
:
|
|
324
|
-
:
|
|
321
|
+
store: :YAML,
|
|
322
|
+
options: 'file: File.join(make_tempdir, "simple_yaml")',
|
|
323
|
+
specs: STANDARD_SPECS.without_marshallable_value.without_concurrent,
|
|
324
|
+
load_value: 'value'
|
|
325
325
|
},
|
|
326
326
|
'standard_yaml_with_expires' => {
|
|
327
|
-
:
|
|
328
|
-
:
|
|
329
|
-
:
|
|
330
|
-
:
|
|
327
|
+
store: :YAML,
|
|
328
|
+
options: 'file: File.join(make_tempdir, "simple_yaml_with_expires"), expires: true',
|
|
329
|
+
specs: STANDARD_SPECS.without_marshallable_value.with_expires.without_concurrent,
|
|
330
|
+
load_value: 'value'
|
|
331
331
|
},
|
|
332
332
|
'standard_localmemcache' => {
|
|
333
|
-
:
|
|
334
|
-
:
|
|
335
|
-
:
|
|
333
|
+
store: :LocalMemCache,
|
|
334
|
+
options: 'file: File.join(make_tempdir, "simple_localmemcache")',
|
|
335
|
+
specs: STANDARD_SPECS.without_increment.without_create
|
|
336
336
|
},
|
|
337
337
|
'standard_localmemcache_with_expires' => {
|
|
338
|
-
:
|
|
339
|
-
:
|
|
340
|
-
:
|
|
338
|
+
store: :LocalMemCache,
|
|
339
|
+
options: 'file: File.join(make_tempdir, "simple_localmemcache_with_expires"), expires: true',
|
|
340
|
+
specs: STANDARD_SPECS.without_increment.without_create.with_expires
|
|
341
341
|
},
|
|
342
342
|
'standard_tokyocabinet' => {
|
|
343
|
-
:
|
|
344
|
-
:
|
|
345
|
-
:
|
|
343
|
+
store: :TokyoCabinet,
|
|
344
|
+
options: 'file: File.join(make_tempdir, "simple_tokyocabinet")',
|
|
345
|
+
specs: STANDARD_SPECS.without_multiprocess
|
|
346
346
|
},
|
|
347
347
|
'standard_tokyocabinet_with_expires' => {
|
|
348
|
-
:
|
|
349
|
-
:
|
|
350
|
-
:
|
|
348
|
+
store: :TokyoCabinet,
|
|
349
|
+
options: 'file: File.join(make_tempdir, "simple_tokyocabinet_with_expires"), expires: true',
|
|
350
|
+
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
|
351
351
|
},
|
|
352
352
|
'standard_tokyotyrant' => {
|
|
353
|
-
:
|
|
354
|
-
:
|
|
353
|
+
store: :TokyoTyrant,
|
|
354
|
+
specs: STANDARD_SPECS
|
|
355
355
|
},
|
|
356
356
|
'standard_tokyotyrant_with_expires' => {
|
|
357
|
-
:
|
|
358
|
-
:
|
|
359
|
-
:
|
|
357
|
+
store: :TokyoTyrant,
|
|
358
|
+
options: 'expires: true',
|
|
359
|
+
specs: STANDARD_SPECS.with_expires
|
|
360
360
|
},
|
|
361
361
|
'standard_kyotocabinet' => {
|
|
362
|
-
:
|
|
363
|
-
:
|
|
364
|
-
:
|
|
362
|
+
store: :KyotoCabinet,
|
|
363
|
+
options: 'file: File.join(make_tempdir, "simple_kyotocabinet.kch")',
|
|
364
|
+
specs: STANDARD_SPECS.without_multiprocess
|
|
365
365
|
},
|
|
366
366
|
'standard_kyotocabinet_with_expires' => {
|
|
367
|
-
:
|
|
368
|
-
:
|
|
369
|
-
:
|
|
367
|
+
store: :KyotoCabinet,
|
|
368
|
+
options: 'file: File.join(make_tempdir, "simple_kyotocabinet_with_expires.kch"), expires: true',
|
|
369
|
+
specs: STANDARD_SPECS.without_multiprocess.with_expires
|
|
370
370
|
},
|
|
371
371
|
'standard_sqlite' => {
|
|
372
|
-
:
|
|
373
|
-
:
|
|
374
|
-
:
|
|
372
|
+
store: :Sqlite,
|
|
373
|
+
options: 'file: File.join(make_tempdir, "simple_sqlite")',
|
|
374
|
+
specs: STANDARD_SPECS.without_concurrent
|
|
375
375
|
},
|
|
376
376
|
'standard_sqlite_with_expires' => {
|
|
377
|
-
:
|
|
378
|
-
:
|
|
379
|
-
:
|
|
377
|
+
store: :Sqlite,
|
|
378
|
+
options: 'file: File.join(make_tempdir, "simple_sqlite_with_expires"), expires: true',
|
|
379
|
+
specs: STANDARD_SPECS.with_expires.without_concurrent
|
|
380
380
|
},
|
|
381
381
|
'standard_redis' => {
|
|
382
|
-
:
|
|
383
|
-
:
|
|
382
|
+
store: :Redis,
|
|
383
|
+
specs: STANDARD_SPECS.with_native_expires,
|
|
384
384
|
},
|
|
385
385
|
'standard_memcached' => {
|
|
386
|
-
:
|
|
387
|
-
:
|
|
388
|
-
:
|
|
386
|
+
store: :Memcached,
|
|
387
|
+
specs: STANDARD_SPECS.with_native_expires,
|
|
388
|
+
options: 'namespace: "simple_memcached"'
|
|
389
389
|
},
|
|
390
390
|
'standard_memcached_dalli' => {
|
|
391
|
-
:
|
|
392
|
-
:
|
|
393
|
-
:
|
|
391
|
+
store: :MemcachedDalli,
|
|
392
|
+
specs: STANDARD_SPECS.with_native_expires,
|
|
393
|
+
options: 'namespace: "simple_memcached_dalli"'
|
|
394
394
|
},
|
|
395
395
|
'standard_memcached_native' => {
|
|
396
|
-
:
|
|
397
|
-
:
|
|
398
|
-
:
|
|
396
|
+
store: :MemcachedNative,
|
|
397
|
+
specs: STANDARD_SPECS.with_native_expires,
|
|
398
|
+
options: 'namespace: "simple_memcached_native"'
|
|
399
399
|
},
|
|
400
400
|
'standard_riak' => {
|
|
401
|
-
:
|
|
402
|
-
:
|
|
401
|
+
store: :Riak,
|
|
402
|
+
options: "bucket: 'standard_riak'",
|
|
403
403
|
# We don't want Riak warnings in tests
|
|
404
|
-
:
|
|
405
|
-
:
|
|
404
|
+
preamble: "require 'riak'\n\nRiak.disable_list_keys_warnings = true\n\n",
|
|
405
|
+
specs: STANDARD_SPECS.without_increment.without_create
|
|
406
406
|
},
|
|
407
407
|
'standard_riak_with_expires' => {
|
|
408
|
-
:
|
|
409
|
-
:
|
|
408
|
+
store: :Riak,
|
|
409
|
+
options: "bucket: 'standard_riak_with_expires', expires: true",
|
|
410
410
|
# We don't want Riak warnings in tests
|
|
411
|
-
:
|
|
412
|
-
:
|
|
411
|
+
preamble: "require 'riak'\n\nRiak.disable_list_keys_warnings = true\n\n",
|
|
412
|
+
specs: STANDARD_SPECS.without_increment.with_expires.without_create
|
|
413
413
|
},
|
|
414
414
|
'standard_couch' => {
|
|
415
|
-
:
|
|
416
|
-
:
|
|
417
|
-
:
|
|
418
|
-
:
|
|
415
|
+
store: :Couch,
|
|
416
|
+
options: "db: 'standard_couch'",
|
|
417
|
+
load_value: '::Marshal.load(value.unpack(\'m\').first)',
|
|
418
|
+
specs: STANDARD_SPECS.without_increment
|
|
419
419
|
},
|
|
420
420
|
'standard_couch_with_expires' => {
|
|
421
|
-
:
|
|
422
|
-
:
|
|
423
|
-
:
|
|
424
|
-
:
|
|
421
|
+
store: :Couch,
|
|
422
|
+
options: "db: 'standard_couch_with_expires', expires: true",
|
|
423
|
+
specs: STANDARD_SPECS.without_increment.with_expires,
|
|
424
|
+
load_value: '::Marshal.load(value.unpack(\'m\').first)'
|
|
425
425
|
},
|
|
426
426
|
'standard_mongo' => {
|
|
427
|
-
:
|
|
428
|
-
:
|
|
429
|
-
:
|
|
427
|
+
store: :Mongo,
|
|
428
|
+
options: "db: 'standard_mongo'",
|
|
429
|
+
specs: STANDARD_SPECS.with_native_expires
|
|
430
|
+
},
|
|
431
|
+
'standard_mongo_moped' => {
|
|
432
|
+
store: :MongoMoped,
|
|
433
|
+
options: "db: 'standard_mongo_moped'",
|
|
434
|
+
specs: STANDARD_SPECS.with_native_expires
|
|
435
|
+
},
|
|
436
|
+
'standard_mongo_official' => {
|
|
437
|
+
store: :MongoOfficial,
|
|
438
|
+
options: "db: 'standard_mongo_official'",
|
|
439
|
+
specs: STANDARD_SPECS.with_native_expires
|
|
430
440
|
},
|
|
431
441
|
'standard_null' => {
|
|
432
|
-
:
|
|
433
|
-
:
|
|
442
|
+
store: :Null,
|
|
443
|
+
specs: STANDARD_SPECS.without_increment.without_create.without_store.without_persist
|
|
434
444
|
},
|
|
435
445
|
'null_adapter' => {
|
|
436
|
-
:
|
|
437
|
-
:
|
|
446
|
+
build: 'Moneta::Adapters::Null.new',
|
|
447
|
+
specs: Specs.new(specs: [:null, :not_increment, :not_create, :not_persist])
|
|
438
448
|
},
|
|
439
449
|
'standard_sequel' => {
|
|
440
|
-
:
|
|
441
|
-
:
|
|
442
|
-
:
|
|
443
|
-
:
|
|
450
|
+
store: :Sequel,
|
|
451
|
+
options: 'db: (defined?(JRUBY_VERSION) ? "jdbc:mysql://localhost/moneta?user=root" : "mysql2://root:@localhost/moneta"), table: "simple_sequel"',
|
|
452
|
+
load_value: '::Marshal.load(value)',
|
|
453
|
+
specs: STANDARD_SPECS
|
|
444
454
|
},
|
|
445
455
|
'standard_sequel_with_expires' => {
|
|
446
|
-
:
|
|
447
|
-
:
|
|
448
|
-
:
|
|
449
|
-
:
|
|
456
|
+
store: :Sequel,
|
|
457
|
+
options: 'db: (defined?(JRUBY_VERSION) ? "jdbc:mysql://localhost/moneta?user=root" : "mysql2://root:@localhost/moneta"), table: "simple_sequel_with_expires", expires: true',
|
|
458
|
+
specs: STANDARD_SPECS.with_expires,
|
|
459
|
+
load_value: '::Marshal.load(value)'
|
|
450
460
|
},
|
|
451
461
|
'standard_datamapper' => {
|
|
452
|
-
:
|
|
453
|
-
:
|
|
454
|
-
:
|
|
462
|
+
store: :DataMapper,
|
|
463
|
+
specs: STANDARD_SPECS.without_increment,
|
|
464
|
+
options: 'setup: "mysql://root:@localhost/moneta", table: "simple_datamapper"',
|
|
455
465
|
# DataMapper needs default repository to be setup
|
|
456
|
-
:
|
|
457
|
-
:
|
|
466
|
+
preamble: "require 'dm-core'\nDataMapper.setup(:default, adapter: :in_memory)\n",
|
|
467
|
+
load_value: '::Marshal.load(value.unpack(\'m\').first)'
|
|
458
468
|
},
|
|
459
469
|
'standard_datamapper_with_expires' => {
|
|
460
|
-
:
|
|
461
|
-
:
|
|
470
|
+
store: :DataMapper,
|
|
471
|
+
options: 'setup: "mysql://root:@localhost/moneta", table: "simple_datamapper_with_expires", expires: true',
|
|
462
472
|
# DataMapper needs default repository to be setup
|
|
463
|
-
:
|
|
464
|
-
:
|
|
465
|
-
:
|
|
473
|
+
preamble: "require 'dm-core'\nDataMapper.setup(:default, adapter: :in_memory)\n",
|
|
474
|
+
specs: STANDARD_SPECS.without_increment.with_expires,
|
|
475
|
+
load_value: '::Marshal.load(value.unpack(\'m\').first)'
|
|
466
476
|
},
|
|
467
477
|
'standard_datamapper_with_repository' => {
|
|
468
|
-
:
|
|
469
|
-
:
|
|
470
|
-
:
|
|
478
|
+
store: :DataMapper,
|
|
479
|
+
specs: STANDARD_SPECS.without_increment,
|
|
480
|
+
options: 'repository: :repo, setup: "mysql://root:@localhost/moneta", table: "simple_datamapper_with_repository"',
|
|
471
481
|
# DataMapper needs default repository to be setup
|
|
472
|
-
:
|
|
473
|
-
:
|
|
482
|
+
preamble: "require 'dm-core'\nDataMapper.setup(:default, adapter: :in_memory)\n",
|
|
483
|
+
load_value: '::Marshal.load(value.unpack(\'m\').first)'
|
|
474
484
|
},
|
|
475
485
|
'standard_activerecord' => {
|
|
476
|
-
:
|
|
477
|
-
:
|
|
478
|
-
:
|
|
479
|
-
:
|
|
486
|
+
store: :ActiveRecord,
|
|
487
|
+
specs: STANDARD_SPECS,
|
|
488
|
+
options: "table: 'standard_activerecord', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta', username: 'root' }",
|
|
489
|
+
load_value: '::Marshal.load(value.unpack(\'m\').first)'
|
|
480
490
|
},
|
|
481
491
|
'standard_activerecord_with_expires' => {
|
|
482
|
-
:
|
|
483
|
-
:
|
|
484
|
-
:
|
|
485
|
-
:
|
|
492
|
+
store: :ActiveRecord,
|
|
493
|
+
options: "table: 'standard_activerecord_with_expires', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta', username: 'root' }, expires: true",
|
|
494
|
+
specs: STANDARD_SPECS.with_expires,
|
|
495
|
+
load_value: '::Marshal.load(value.unpack(\'m\').first)'
|
|
486
496
|
},
|
|
487
497
|
'standard_fog' => {
|
|
488
|
-
:
|
|
489
|
-
:
|
|
490
|
-
:
|
|
491
|
-
:
|
|
492
|
-
:
|
|
493
|
-
:
|
|
498
|
+
store: :Fog,
|
|
499
|
+
specs: STANDARD_SPECS.without_increment.without_create,
|
|
500
|
+
options: "aws_access_key_id: 'fake_access_key_id',
|
|
501
|
+
aws_secret_access_key: 'fake_secret_access_key',
|
|
502
|
+
provider: 'AWS',
|
|
503
|
+
dir: 'standard_fog'",
|
|
494
504
|
# Put Fog into testing mode
|
|
495
|
-
:
|
|
505
|
+
preamble: "require 'fog'\nFog.mock!\n"
|
|
496
506
|
},
|
|
497
507
|
'standard_fog_with_expires' => {
|
|
498
|
-
:
|
|
499
|
-
:
|
|
500
|
-
:
|
|
501
|
-
:
|
|
502
|
-
:
|
|
503
|
-
:
|
|
508
|
+
store: :Fog,
|
|
509
|
+
options: "aws_access_key_id: 'fake_access_key_id',
|
|
510
|
+
aws_secret_access_key: 'fake_secret_access_key',
|
|
511
|
+
provider: 'AWS',
|
|
512
|
+
dir: 'standard_fog_with_expires',
|
|
513
|
+
expires: true",
|
|
504
514
|
# Put Fog into testing mode
|
|
505
|
-
:
|
|
506
|
-
:
|
|
515
|
+
preamble: "require 'fog'\nFog.mock!\n",
|
|
516
|
+
specs: STANDARD_SPECS.without_increment.without_create.with_expires
|
|
507
517
|
},
|
|
508
518
|
'weak_create' => {
|
|
509
519
|
# Put Fog into testing mode
|
|
510
|
-
:
|
|
511
|
-
:
|
|
520
|
+
preamble: "require 'fog'\nFog.mock!\n",
|
|
521
|
+
build: %{Moneta.build do
|
|
512
522
|
use :WeakCreate
|
|
513
523
|
adapter :Fog,
|
|
514
|
-
:
|
|
515
|
-
:
|
|
516
|
-
:
|
|
517
|
-
:
|
|
524
|
+
aws_access_key_id: 'fake_access_key_id',
|
|
525
|
+
aws_secret_access_key: 'fake_secret_access_key',
|
|
526
|
+
provider: 'AWS',
|
|
527
|
+
dir: 'weak_create'
|
|
518
528
|
end},
|
|
519
|
-
:
|
|
529
|
+
specs: ADAPTER_SPECS.without_increment.without_concurrent.returnsame
|
|
520
530
|
},
|
|
521
531
|
'weak_increment' => {
|
|
522
532
|
# Put Fog into testing mode
|
|
523
|
-
:
|
|
524
|
-
:
|
|
533
|
+
preamble: "require 'fog'\nFog.mock!\n",
|
|
534
|
+
build: %{Moneta.build do
|
|
525
535
|
use :WeakIncrement
|
|
526
536
|
adapter :Fog,
|
|
527
|
-
:
|
|
528
|
-
:
|
|
529
|
-
:
|
|
530
|
-
:
|
|
537
|
+
aws_access_key_id: 'fake_access_key_id',
|
|
538
|
+
aws_secret_access_key: 'fake_secret_access_key',
|
|
539
|
+
provider: 'AWS',
|
|
540
|
+
dir: 'weak_increment'
|
|
531
541
|
end},
|
|
532
|
-
:
|
|
542
|
+
specs: ADAPTER_SPECS.without_create.without_concurrent.returnsame
|
|
533
543
|
},
|
|
534
544
|
'expires_memory' => {
|
|
535
|
-
:
|
|
545
|
+
build: %{Moneta.build do
|
|
536
546
|
use :Expires
|
|
537
547
|
adapter :Memory
|
|
538
548
|
end},
|
|
539
|
-
:
|
|
549
|
+
specs: STANDARD_SPECS.without_transform.with_expires.without_persist.returnsame
|
|
540
550
|
},
|
|
541
551
|
'expires_memory_with_default_expires' => {
|
|
542
|
-
:
|
|
543
|
-
use :Expires, :
|
|
552
|
+
build: %{Moneta.build do
|
|
553
|
+
use :Expires, expires: 1
|
|
544
554
|
adapter :Memory
|
|
545
555
|
end},
|
|
546
|
-
:
|
|
556
|
+
specs: STANDARD_SPECS.without_transform.with_expires.with_default_expires.without_persist.returnsame
|
|
547
557
|
},
|
|
548
558
|
'expires_file' => {
|
|
549
|
-
:
|
|
559
|
+
build: %{Moneta.build do
|
|
550
560
|
use :Expires
|
|
551
|
-
use :Transformer, :
|
|
552
|
-
adapter :File, :
|
|
561
|
+
use :Transformer, key: [:marshal, :escape], value: :marshal
|
|
562
|
+
adapter :File, dir: File.join(make_tempdir, "expires-file")
|
|
553
563
|
end},
|
|
554
|
-
:
|
|
555
|
-
:
|
|
564
|
+
specs: STANDARD_SPECS.with_expires.stringvalues_only,
|
|
565
|
+
tests: %{
|
|
556
566
|
it 'deletes expired value in underlying file storage' do
|
|
557
|
-
store.store('foo', 'bar', :
|
|
567
|
+
store.store('foo', 'bar', expires: 2)
|
|
558
568
|
store['foo'].should == 'bar'
|
|
559
569
|
sleep 1
|
|
560
570
|
store['foo'].should == 'bar'
|
|
@@ -566,31 +576,31 @@ end
|
|
|
566
576
|
}
|
|
567
577
|
},
|
|
568
578
|
'proxy_redis' => {
|
|
569
|
-
:
|
|
579
|
+
build: %{Moneta.build do
|
|
570
580
|
use :Proxy
|
|
571
581
|
use :Proxy
|
|
572
582
|
adapter :Redis
|
|
573
583
|
end},
|
|
574
|
-
:
|
|
584
|
+
specs: ADAPTER_SPECS.with_expires
|
|
575
585
|
},
|
|
576
586
|
'proxy_expires_memory' => {
|
|
577
|
-
:
|
|
587
|
+
build: %{Moneta.build do
|
|
578
588
|
use :Proxy
|
|
579
589
|
use :Expires
|
|
580
590
|
use :Proxy
|
|
581
591
|
adapter :Memory
|
|
582
592
|
end},
|
|
583
|
-
:
|
|
593
|
+
specs: STANDARD_SPECS.without_transform.with_expires.returnsame.without_persist
|
|
584
594
|
},
|
|
585
595
|
'cache_file_memory' => {
|
|
586
|
-
:
|
|
596
|
+
build: %{Moneta.build do
|
|
587
597
|
use(:Cache) do
|
|
588
|
-
adapter { adapter :File, :
|
|
598
|
+
adapter { adapter :File, dir: File.join(make_tempdir, "cache_file_memory") }
|
|
589
599
|
cache { adapter :Memory }
|
|
590
600
|
end
|
|
591
601
|
end},
|
|
592
|
-
:
|
|
593
|
-
:
|
|
602
|
+
specs: ADAPTER_SPECS.returnsame,
|
|
603
|
+
tests: %{
|
|
594
604
|
it 'stores loaded values in cache' do
|
|
595
605
|
store.adapter['foo'] = 'bar'
|
|
596
606
|
store.cache['foo'].should be_nil
|
|
@@ -604,22 +614,22 @@ end
|
|
|
604
614
|
}
|
|
605
615
|
},
|
|
606
616
|
'cache_memory_null' => {
|
|
607
|
-
:
|
|
617
|
+
build: %{Moneta.build do
|
|
608
618
|
use(:Cache) do
|
|
609
619
|
adapter(Moneta::Adapters::Memory.new)
|
|
610
620
|
cache(Moneta::Adapters::Null.new)
|
|
611
621
|
end
|
|
612
622
|
end},
|
|
613
|
-
:
|
|
623
|
+
specs: ADAPTER_SPECS.without_persist.returnsame
|
|
614
624
|
},
|
|
615
625
|
'shared_tcp' => {
|
|
616
|
-
:
|
|
617
|
-
use(:Shared, :
|
|
618
|
-
adapter :PStore, :
|
|
626
|
+
build: %{Moneta.build do
|
|
627
|
+
use(:Shared, port: 9001) do
|
|
628
|
+
adapter :PStore, file: File.join(make_tempdir, 'shared_tcp')
|
|
619
629
|
end
|
|
620
630
|
end},
|
|
621
|
-
:
|
|
622
|
-
:
|
|
631
|
+
specs: ADAPTER_SPECS,
|
|
632
|
+
tests: %{
|
|
623
633
|
it 'shares values' do
|
|
624
634
|
store['shared_key'] = 'shared_value'
|
|
625
635
|
second = new_store
|
|
@@ -630,13 +640,13 @@ end
|
|
|
630
640
|
}
|
|
631
641
|
},
|
|
632
642
|
'shared_unix' => {
|
|
633
|
-
:
|
|
634
|
-
use(:Shared, :
|
|
635
|
-
adapter :PStore, :
|
|
643
|
+
build: %{Moneta.build do
|
|
644
|
+
use(:Shared, socket: File.join(make_tempdir, 'shared_unix.socket')) do
|
|
645
|
+
adapter :PStore, file: File.join(make_tempdir, 'shared_unix')
|
|
636
646
|
end
|
|
637
647
|
end},
|
|
638
|
-
:
|
|
639
|
-
:
|
|
648
|
+
specs: ADAPTER_SPECS,
|
|
649
|
+
tests: %{
|
|
640
650
|
it 'shares values' do
|
|
641
651
|
store['shared_key'] = 'shared_value'
|
|
642
652
|
second = new_store
|
|
@@ -647,165 +657,165 @@ end
|
|
|
647
657
|
}
|
|
648
658
|
},
|
|
649
659
|
'stack_file_memory' => {
|
|
650
|
-
:
|
|
660
|
+
build: %{Moneta.build do
|
|
651
661
|
use(:Stack) do
|
|
652
662
|
add(Moneta.new(:Null))
|
|
653
663
|
add(Moneta::Adapters::Null.new)
|
|
654
|
-
add { adapter :File, :
|
|
664
|
+
add { adapter :File, dir: File.join(make_tempdir, "stack_file_memory") }
|
|
655
665
|
add { adapter :Memory }
|
|
656
666
|
end
|
|
657
667
|
end},
|
|
658
|
-
:
|
|
668
|
+
specs: ADAPTER_SPECS.without_increment.without_create
|
|
659
669
|
},
|
|
660
670
|
'stack_memory_file' => {
|
|
661
|
-
:
|
|
671
|
+
build: %{Moneta.build do
|
|
662
672
|
use(:Stack) do
|
|
663
673
|
add { adapter :Memory }
|
|
664
|
-
add { adapter :File, :
|
|
674
|
+
add { adapter :File, dir: File.join(make_tempdir, "stack_memory_file") }
|
|
665
675
|
end
|
|
666
676
|
end},
|
|
667
|
-
:
|
|
677
|
+
specs: ADAPTER_SPECS.returnsame
|
|
668
678
|
},
|
|
669
679
|
'lock' => {
|
|
670
|
-
:
|
|
680
|
+
build: %{Moneta.build do
|
|
671
681
|
use :Lock
|
|
672
682
|
adapter :Memory
|
|
673
683
|
end},
|
|
674
|
-
:
|
|
684
|
+
specs: STANDARD_SPECS.without_transform.returnsame.without_persist
|
|
675
685
|
},
|
|
676
686
|
'pool' => {
|
|
677
|
-
:
|
|
687
|
+
build: %{Moneta.build do
|
|
678
688
|
use :Pool do
|
|
679
|
-
adapter :File, :
|
|
689
|
+
adapter :File, dir: File.join(make_tempdir, "pool")
|
|
680
690
|
end
|
|
681
691
|
end},
|
|
682
|
-
:
|
|
692
|
+
specs: ADAPTER_SPECS
|
|
683
693
|
},
|
|
684
694
|
'transformer_zlib' => {
|
|
685
|
-
:
|
|
686
|
-
use :Transformer, :
|
|
695
|
+
build: %{Moneta.build do
|
|
696
|
+
use :Transformer, value: :zlib
|
|
687
697
|
adapter :Memory
|
|
688
698
|
end},
|
|
689
|
-
:
|
|
690
|
-
:
|
|
691
|
-
:
|
|
699
|
+
specs: TRANSFORMER_SPECS.stringvalues_only,
|
|
700
|
+
load_value: '::Zlib::Inflate.inflate(value)',
|
|
701
|
+
tests: %{
|
|
692
702
|
it 'compile transformer class' do
|
|
693
703
|
store.should_not be_nil
|
|
694
704
|
Moneta::Transformer::ZlibValue.should_not be_nil
|
|
695
705
|
end}
|
|
696
706
|
},
|
|
697
707
|
'transformer_bzip2' => {
|
|
698
|
-
:
|
|
699
|
-
use :Transformer, :
|
|
708
|
+
build: %{Moneta.build do
|
|
709
|
+
use :Transformer, value: :bzip2
|
|
700
710
|
adapter :Memory
|
|
701
711
|
end},
|
|
702
|
-
:
|
|
703
|
-
:
|
|
704
|
-
:
|
|
712
|
+
specs: TRANSFORMER_SPECS.stringvalues_only,
|
|
713
|
+
load_value: '::Bzip2.uncompress(value)',
|
|
714
|
+
tests: %{
|
|
705
715
|
it 'compile transformer class' do
|
|
706
716
|
store.should_not be_nil
|
|
707
717
|
Moneta::Transformer::Bzip2Value.should_not be_nil
|
|
708
718
|
end}
|
|
709
719
|
},
|
|
710
720
|
'transformer_lzo' => {
|
|
711
|
-
:
|
|
712
|
-
use :Transformer, :
|
|
721
|
+
build: %{Moneta.build do
|
|
722
|
+
use :Transformer, value: :lzo
|
|
713
723
|
adapter :Memory
|
|
714
724
|
end},
|
|
715
|
-
:
|
|
716
|
-
:
|
|
717
|
-
:
|
|
725
|
+
specs: TRANSFORMER_SPECS.stringvalues_only,
|
|
726
|
+
load_value: '::LZO.decompress(value)',
|
|
727
|
+
tests: %{
|
|
718
728
|
it 'compile transformer class' do
|
|
719
729
|
store.should_not be_nil
|
|
720
730
|
Moneta::Transformer::LzoValue.should_not be_nil
|
|
721
731
|
end}
|
|
722
732
|
},
|
|
723
733
|
'transformer_lz4' => {
|
|
724
|
-
:
|
|
725
|
-
use :Transformer, :
|
|
734
|
+
build: %{Moneta.build do
|
|
735
|
+
use :Transformer, value: :lz4
|
|
726
736
|
adapter :Memory
|
|
727
737
|
end},
|
|
728
|
-
:
|
|
729
|
-
:
|
|
730
|
-
:
|
|
738
|
+
specs: TRANSFORMER_SPECS.stringvalues_only,
|
|
739
|
+
load_value: '::LZ4.uncompress(value)',
|
|
740
|
+
tests: %{
|
|
731
741
|
it 'compile transformer class' do
|
|
732
742
|
store.should_not be_nil
|
|
733
743
|
Moneta::Transformer::Lz4Value.should_not be_nil
|
|
734
744
|
end}
|
|
735
745
|
},
|
|
736
746
|
'transformer_lzma' => {
|
|
737
|
-
:
|
|
738
|
-
use :Transformer, :
|
|
747
|
+
build: %{Moneta.build do
|
|
748
|
+
use :Transformer, value: :lzma
|
|
739
749
|
adapter :Memory
|
|
740
750
|
end},
|
|
741
|
-
:
|
|
742
|
-
:
|
|
743
|
-
:
|
|
751
|
+
specs: TRANSFORMER_SPECS.stringvalues_only,
|
|
752
|
+
load_value: '::LZMA.decompress(value)',
|
|
753
|
+
tests: %{
|
|
744
754
|
it 'compile transformer class' do
|
|
745
755
|
store.should_not be_nil
|
|
746
756
|
Moneta::Transformer::LzmaValue.should_not be_nil
|
|
747
757
|
end}
|
|
748
758
|
},
|
|
749
759
|
'transformer_snappy' => {
|
|
750
|
-
:
|
|
751
|
-
use :Transformer, :
|
|
760
|
+
build: %{Moneta.build do
|
|
761
|
+
use :Transformer, value: :snappy
|
|
752
762
|
adapter :Memory
|
|
753
763
|
end},
|
|
754
|
-
:
|
|
755
|
-
:
|
|
756
|
-
:
|
|
764
|
+
specs: TRANSFORMER_SPECS.stringvalues_only,
|
|
765
|
+
load_value: '::Snappy.inflate(value)',
|
|
766
|
+
tests: %{
|
|
757
767
|
it 'compile transformer class' do
|
|
758
768
|
store.should_not be_nil
|
|
759
769
|
Moneta::Transformer::SnappyValue.should_not be_nil
|
|
760
770
|
end}
|
|
761
771
|
},
|
|
762
772
|
'transformer_quicklz' => {
|
|
763
|
-
:
|
|
764
|
-
use :Transformer, :
|
|
773
|
+
build: %{Moneta.build do
|
|
774
|
+
use :Transformer, value: :quicklz
|
|
765
775
|
adapter :Memory
|
|
766
776
|
end},
|
|
767
|
-
:
|
|
768
|
-
:
|
|
769
|
-
:
|
|
777
|
+
specs: TRANSFORMER_SPECS.stringvalues_only,
|
|
778
|
+
load_value: '::QuickLZ.decompress(value)',
|
|
779
|
+
tests: %{
|
|
770
780
|
it 'compile transformer class' do
|
|
771
781
|
store.should_not be_nil
|
|
772
782
|
Moneta::Transformer::QuicklzValue.should_not be_nil
|
|
773
783
|
end}
|
|
774
784
|
},
|
|
775
785
|
'transformer_json' => {
|
|
776
|
-
:
|
|
777
|
-
use :Transformer, :
|
|
786
|
+
build: %{Moneta.build do
|
|
787
|
+
use :Transformer, key: :json, value: :json
|
|
778
788
|
adapter :Memory
|
|
779
789
|
end},
|
|
780
|
-
:
|
|
781
|
-
:
|
|
782
|
-
:
|
|
790
|
+
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
|
791
|
+
load_value: '::MultiJson.load(value)',
|
|
792
|
+
tests: %{
|
|
783
793
|
it 'compile transformer class' do
|
|
784
794
|
store.should_not be_nil
|
|
785
795
|
Moneta::Transformer::JsonKeyJsonValue.should_not be_nil
|
|
786
796
|
end}
|
|
787
797
|
},
|
|
788
798
|
'transformer_bert' => {
|
|
789
|
-
:
|
|
790
|
-
use :Transformer, :
|
|
799
|
+
build: %{Moneta.build do
|
|
800
|
+
use :Transformer, key: :bert, value: :bert
|
|
791
801
|
adapter :Memory
|
|
792
802
|
end},
|
|
793
|
-
:
|
|
794
|
-
:
|
|
795
|
-
:
|
|
803
|
+
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
|
804
|
+
load_value: '::BERT.decode(value)',
|
|
805
|
+
tests: %{
|
|
796
806
|
it 'compile transformer class' do
|
|
797
807
|
store.should_not be_nil
|
|
798
808
|
Moneta::Transformer::BertKeyBertValue.should_not be_nil
|
|
799
809
|
end}
|
|
800
810
|
},
|
|
801
811
|
'transformer_bencode' => {
|
|
802
|
-
:
|
|
803
|
-
use :Transformer, :
|
|
812
|
+
build: %{Moneta.build do
|
|
813
|
+
use :Transformer, key: :bencode, value: :bencode
|
|
804
814
|
adapter :Memory
|
|
805
815
|
end},
|
|
806
|
-
:
|
|
807
|
-
:
|
|
808
|
-
:
|
|
816
|
+
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
|
817
|
+
load_value: '::BEncode.load(value)',
|
|
818
|
+
tests: %{
|
|
809
819
|
it 'compile transformer class' do
|
|
810
820
|
store.should_not be_nil
|
|
811
821
|
Moneta::Transformer::BencodeKeyBencodeValue.should_not be_nil
|
|
@@ -813,408 +823,408 @@ end}
|
|
|
813
823
|
|
|
814
824
|
},
|
|
815
825
|
'transformer_bson' => {
|
|
816
|
-
:
|
|
817
|
-
use :Transformer, :
|
|
826
|
+
build: %{Moneta.build do
|
|
827
|
+
use :Transformer, key: :bson, value: :bson
|
|
818
828
|
adapter :Memory
|
|
819
829
|
end},
|
|
820
|
-
:
|
|
821
|
-
:
|
|
822
|
-
:
|
|
830
|
+
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
|
831
|
+
load_value: "::BSON.deserialize(value)['v']",
|
|
832
|
+
tests: %{
|
|
823
833
|
it 'compile transformer class' do
|
|
824
834
|
store.should_not be_nil
|
|
825
835
|
Moneta::Transformer::BsonKeyBsonValue.should_not be_nil
|
|
826
836
|
end}
|
|
827
837
|
},
|
|
828
838
|
'transformer_ox' => {
|
|
829
|
-
:
|
|
830
|
-
use :Transformer, :
|
|
839
|
+
build: %{Moneta.build do
|
|
840
|
+
use :Transformer, key: :ox, value: :ox
|
|
831
841
|
adapter :Memory
|
|
832
842
|
end},
|
|
833
|
-
:
|
|
834
|
-
:
|
|
835
|
-
:
|
|
843
|
+
specs: TRANSFORMER_SPECS,
|
|
844
|
+
load_value: '::Ox.parse_obj(value)',
|
|
845
|
+
tests: %{
|
|
836
846
|
it 'compile transformer class' do
|
|
837
847
|
store.should_not be_nil
|
|
838
848
|
Moneta::Transformer::OxKeyOxValue.should_not be_nil
|
|
839
849
|
end}
|
|
840
850
|
},
|
|
841
851
|
'transformer_php' => {
|
|
842
|
-
:
|
|
843
|
-
use :Transformer, :
|
|
852
|
+
build: %{Moneta.build do
|
|
853
|
+
use :Transformer, key: :php, value: :php
|
|
844
854
|
adapter :Memory
|
|
845
855
|
end},
|
|
846
|
-
:
|
|
847
|
-
:
|
|
848
|
-
:
|
|
856
|
+
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
|
857
|
+
load_value: '::PHP.unserialize(value)',
|
|
858
|
+
tests: %{
|
|
849
859
|
it 'compile transformer class' do
|
|
850
860
|
store.should_not be_nil
|
|
851
861
|
Moneta::Transformer::PhpKeyPhpValue.should_not be_nil
|
|
852
862
|
end}
|
|
853
863
|
},
|
|
854
864
|
'transformer_tnet' => {
|
|
855
|
-
:
|
|
856
|
-
use :Transformer, :
|
|
865
|
+
build: %{Moneta.build do
|
|
866
|
+
use :Transformer, key: :tnet, value: :tnet
|
|
857
867
|
adapter :Memory
|
|
858
868
|
end},
|
|
859
|
-
:
|
|
860
|
-
:
|
|
861
|
-
:
|
|
869
|
+
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
|
870
|
+
load_value: '::TNetstring.parse(value).first',
|
|
871
|
+
tests: %{
|
|
862
872
|
it 'compile transformer class' do
|
|
863
873
|
store.should_not be_nil
|
|
864
874
|
Moneta::Transformer::TnetKeyTnetValue.should_not be_nil
|
|
865
875
|
end}
|
|
866
876
|
},
|
|
867
877
|
'transformer_msgpack' => {
|
|
868
|
-
:
|
|
869
|
-
use :Transformer, :
|
|
878
|
+
build: %{Moneta.build do
|
|
879
|
+
use :Transformer, key: :msgpack, value: :msgpack
|
|
870
880
|
adapter :Memory
|
|
871
881
|
end},
|
|
872
|
-
:
|
|
873
|
-
:
|
|
874
|
-
:
|
|
882
|
+
specs: TRANSFORMER_SPECS.simplekeys_only.simplevalues_only,
|
|
883
|
+
load_value: '::MessagePack.unpack(value)',
|
|
884
|
+
tests: %{
|
|
875
885
|
it 'compile transformer class' do
|
|
876
886
|
store.should_not be_nil
|
|
877
887
|
Moneta::Transformer::MsgpackKeyMsgpackValue.should_not be_nil
|
|
878
888
|
end}
|
|
879
889
|
},
|
|
880
890
|
'transformer_marshal' => {
|
|
881
|
-
:
|
|
882
|
-
use :Transformer, :
|
|
891
|
+
build: %{Moneta.build do
|
|
892
|
+
use :Transformer, key: :marshal, value: :marshal
|
|
883
893
|
adapter :Memory
|
|
884
894
|
end},
|
|
885
|
-
:
|
|
886
|
-
:
|
|
887
|
-
:
|
|
895
|
+
specs: TRANSFORMER_SPECS,
|
|
896
|
+
load_value: '::Marshal.load(value)',
|
|
897
|
+
tests: %{
|
|
888
898
|
it 'compile transformer class' do
|
|
889
899
|
store.should_not be_nil
|
|
890
900
|
Moneta::Transformer::MarshalKeyMarshalValue.should_not be_nil
|
|
891
901
|
end}
|
|
892
902
|
},
|
|
893
903
|
'transformer_key_marshal' => {
|
|
894
|
-
:
|
|
895
|
-
use :Transformer, :
|
|
904
|
+
build: %{Moneta.build do
|
|
905
|
+
use :Transformer, key: :marshal
|
|
896
906
|
adapter :Memory
|
|
897
907
|
end},
|
|
898
|
-
:
|
|
899
|
-
:
|
|
900
|
-
:
|
|
908
|
+
specs: TRANSFORMER_SPECS.returnsame,
|
|
909
|
+
load_value: 'value',
|
|
910
|
+
tests: %{
|
|
901
911
|
it 'compile transformer class' do
|
|
902
912
|
store.should_not be_nil
|
|
903
913
|
Moneta::Transformer::MarshalKey.should_not be_nil
|
|
904
914
|
end}
|
|
905
915
|
},
|
|
906
916
|
'transformer_key_to_s' => {
|
|
907
|
-
:
|
|
908
|
-
use :Transformer, :
|
|
917
|
+
build: %{Moneta.build do
|
|
918
|
+
use :Transformer, key: :to_s
|
|
909
919
|
adapter :Memory
|
|
910
920
|
end},
|
|
911
|
-
:
|
|
912
|
-
:
|
|
913
|
-
:
|
|
921
|
+
specs: TRANSFORMER_SPECS.returnsame.simplekeys_only,
|
|
922
|
+
load_value: 'value',
|
|
923
|
+
tests: %{
|
|
914
924
|
it 'compile transformer class' do
|
|
915
925
|
store.should_not be_nil
|
|
916
926
|
Moneta::Transformer::To_sKey.should_not be_nil
|
|
917
927
|
end}
|
|
918
928
|
},
|
|
919
929
|
'transformer_key_inspect' => {
|
|
920
|
-
:
|
|
921
|
-
use :Transformer, :
|
|
930
|
+
build: %{Moneta.build do
|
|
931
|
+
use :Transformer, key: :inspect
|
|
922
932
|
adapter :Memory
|
|
923
933
|
end},
|
|
924
|
-
:
|
|
925
|
-
:
|
|
926
|
-
:
|
|
934
|
+
specs: TRANSFORMER_SPECS.returnsame.simplekeys_only,
|
|
935
|
+
load_value: 'value',
|
|
936
|
+
tests: %{
|
|
927
937
|
it 'compile transformer class' do
|
|
928
938
|
store.should_not be_nil
|
|
929
939
|
Moneta::Transformer::InspectKey.should_not be_nil
|
|
930
940
|
end}
|
|
931
941
|
},
|
|
932
942
|
'transformer_value_marshal' => {
|
|
933
|
-
:
|
|
934
|
-
use :Transformer, :
|
|
943
|
+
build: %{Moneta.build do
|
|
944
|
+
use :Transformer, value: :marshal
|
|
935
945
|
adapter :Memory
|
|
936
946
|
end},
|
|
937
|
-
:
|
|
938
|
-
:
|
|
939
|
-
:
|
|
947
|
+
specs: TRANSFORMER_SPECS,
|
|
948
|
+
load_value: '::Marshal.load(value)',
|
|
949
|
+
tests: %{
|
|
940
950
|
it 'compile transformer class' do
|
|
941
951
|
store.should_not be_nil
|
|
942
952
|
Moneta::Transformer::MarshalValue.should_not be_nil
|
|
943
953
|
end}
|
|
944
954
|
},
|
|
945
955
|
'transformer_yaml' => {
|
|
946
|
-
:
|
|
947
|
-
use :Transformer, :
|
|
956
|
+
build: %{Moneta.build do
|
|
957
|
+
use :Transformer, key: :yaml, value: :yaml
|
|
948
958
|
adapter :Memory
|
|
949
959
|
end},
|
|
950
|
-
:
|
|
951
|
-
:
|
|
952
|
-
:
|
|
960
|
+
specs: TRANSFORMER_SPECS,
|
|
961
|
+
load_value: '::YAML.load(value)',
|
|
962
|
+
tests: %{
|
|
953
963
|
it 'compile transformer class' do
|
|
954
964
|
store.should_not be_nil
|
|
955
965
|
Moneta::Transformer::YamlKeyYamlValue.should_not be_nil
|
|
956
966
|
end}
|
|
957
967
|
},
|
|
958
968
|
'transformer_key_yaml' => {
|
|
959
|
-
:
|
|
960
|
-
use :Transformer, :
|
|
969
|
+
build: %{Moneta.build do
|
|
970
|
+
use :Transformer, key: :yaml
|
|
961
971
|
adapter :Memory
|
|
962
972
|
end},
|
|
963
|
-
:
|
|
964
|
-
:
|
|
965
|
-
:
|
|
973
|
+
specs: TRANSFORMER_SPECS.returnsame,
|
|
974
|
+
load_value: 'value',
|
|
975
|
+
tests: %{
|
|
966
976
|
it 'compile transformer class' do
|
|
967
977
|
store.should_not be_nil
|
|
968
978
|
Moneta::Transformer::YamlKey.should_not be_nil
|
|
969
979
|
end}
|
|
970
980
|
},
|
|
971
981
|
'transformer_value_yaml' => {
|
|
972
|
-
:
|
|
973
|
-
use :Transformer, :
|
|
982
|
+
build: %{Moneta.build do
|
|
983
|
+
use :Transformer, value: :yaml
|
|
974
984
|
adapter :Memory
|
|
975
985
|
end},
|
|
976
|
-
:
|
|
977
|
-
:
|
|
978
|
-
:
|
|
986
|
+
specs: TRANSFORMER_SPECS,
|
|
987
|
+
load_value: '::YAML.load(value)',
|
|
988
|
+
tests: %{
|
|
979
989
|
it 'compile transformer class' do
|
|
980
990
|
store.should_not be_nil
|
|
981
991
|
Moneta::Transformer::YamlValue.should_not be_nil
|
|
982
992
|
end}
|
|
983
993
|
},
|
|
984
994
|
'transformer_marshal_hmac' => {
|
|
985
|
-
:
|
|
986
|
-
use :Transformer, :
|
|
995
|
+
build: %{Moneta.build do
|
|
996
|
+
use :Transformer, key: :marshal, value: [:marshal, :hmac], secret: 'secret'
|
|
987
997
|
adapter :Memory
|
|
988
998
|
end},
|
|
989
|
-
:
|
|
990
|
-
:
|
|
991
|
-
:
|
|
999
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1000
|
+
load_value: '::Marshal.load(::Moneta::Transformer::Helper.hmacverify(value, \'secret\'))',
|
|
1001
|
+
tests: %{
|
|
992
1002
|
it 'compile transformer class' do
|
|
993
1003
|
store.should_not be_nil
|
|
994
1004
|
Moneta::Transformer::MarshalKeyMarshalHmacValue.should_not be_nil
|
|
995
1005
|
end}
|
|
996
1006
|
},
|
|
997
1007
|
'transformer_marshal_base64' => {
|
|
998
|
-
:
|
|
999
|
-
use :Transformer, :
|
|
1008
|
+
build: %{Moneta.build do
|
|
1009
|
+
use :Transformer, key: [:marshal, :base64], value: [:marshal, :base64]
|
|
1000
1010
|
adapter :Memory
|
|
1001
1011
|
end},
|
|
1002
|
-
:
|
|
1003
|
-
:
|
|
1004
|
-
:
|
|
1012
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1013
|
+
load_value: '::Marshal.load(value.unpack(\'m\').first)',
|
|
1014
|
+
tests: %{
|
|
1005
1015
|
it 'compile transformer class' do
|
|
1006
1016
|
store.should_not be_nil
|
|
1007
1017
|
Moneta::Transformer::MarshalBase64KeyMarshalBase64Value.should_not be_nil
|
|
1008
1018
|
end}
|
|
1009
1019
|
},
|
|
1010
1020
|
'transformer_marshal_hex' => {
|
|
1011
|
-
:
|
|
1012
|
-
use :Transformer, :
|
|
1021
|
+
build: %{Moneta.build do
|
|
1022
|
+
use :Transformer, key: [:marshal, :hex], value: [:marshal, :hex]
|
|
1013
1023
|
adapter :Memory
|
|
1014
1024
|
end},
|
|
1015
|
-
:
|
|
1016
|
-
:
|
|
1017
|
-
:
|
|
1025
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1026
|
+
load_value: '::Marshal.load([value].pack(\'H*\'))',
|
|
1027
|
+
tests: %{
|
|
1018
1028
|
it 'compile transformer class' do
|
|
1019
1029
|
store.should_not be_nil
|
|
1020
1030
|
Moneta::Transformer::MarshalHexKeyMarshalHexValue.should_not be_nil
|
|
1021
1031
|
end}
|
|
1022
1032
|
},
|
|
1023
1033
|
'transformer_marshal_prefix' => {
|
|
1024
|
-
:
|
|
1025
|
-
use :Transformer, :
|
|
1034
|
+
build: %{Moneta.build do
|
|
1035
|
+
use :Transformer, key: [:marshal, :prefix], value: :marshal, prefix: 'moneta'
|
|
1026
1036
|
adapter :Memory
|
|
1027
1037
|
end},
|
|
1028
|
-
:
|
|
1029
|
-
:
|
|
1038
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1039
|
+
tests: %{
|
|
1030
1040
|
it 'compile transformer class' do
|
|
1031
1041
|
store.should_not be_nil
|
|
1032
1042
|
Moneta::Transformer::MarshalPrefixKeyMarshalValue.should_not be_nil
|
|
1033
1043
|
end}
|
|
1034
1044
|
},
|
|
1035
1045
|
'transformer_marshal_uuencode' => {
|
|
1036
|
-
:
|
|
1037
|
-
use :Transformer, :
|
|
1046
|
+
build: %{Moneta.build do
|
|
1047
|
+
use :Transformer, key: [:marshal, :uuencode], value: [:marshal, :uuencode]
|
|
1038
1048
|
adapter :Memory
|
|
1039
1049
|
end},
|
|
1040
|
-
:
|
|
1041
|
-
:
|
|
1042
|
-
:
|
|
1050
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1051
|
+
load_value: '::Marshal.load(value.unpack(\'u\').first)',
|
|
1052
|
+
tests: %{
|
|
1043
1053
|
it 'compile transformer class' do
|
|
1044
1054
|
store.should_not be_nil
|
|
1045
1055
|
Moneta::Transformer::MarshalUuencodeKeyMarshalUuencodeValue.should_not be_nil
|
|
1046
1056
|
end}
|
|
1047
1057
|
},
|
|
1048
1058
|
'transformer_marshal_qp' => {
|
|
1049
|
-
:
|
|
1050
|
-
use :Transformer, :
|
|
1059
|
+
build: %{Moneta.build do
|
|
1060
|
+
use :Transformer, key: [:marshal, :qp], value: [:marshal, :qp]
|
|
1051
1061
|
adapter :Memory
|
|
1052
1062
|
end},
|
|
1053
|
-
:
|
|
1054
|
-
:
|
|
1055
|
-
:
|
|
1063
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1064
|
+
load_value: '::Marshal.load(value.unpack(\'M\').first)',
|
|
1065
|
+
tests: %{
|
|
1056
1066
|
it 'compile transformer class' do
|
|
1057
1067
|
store.should_not be_nil
|
|
1058
1068
|
Moneta::Transformer::MarshalQpKeyMarshalQpValue.should_not be_nil
|
|
1059
1069
|
end}
|
|
1060
1070
|
},
|
|
1061
1071
|
'transformer_marshal_escape' => {
|
|
1062
|
-
:
|
|
1063
|
-
use :Transformer, :
|
|
1072
|
+
build: %{Moneta.build do
|
|
1073
|
+
use :Transformer, key: [:marshal, :escape], value: :marshal
|
|
1064
1074
|
adapter :Memory
|
|
1065
1075
|
end},
|
|
1066
|
-
:
|
|
1067
|
-
:
|
|
1076
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1077
|
+
tests: %{
|
|
1068
1078
|
it 'compile transformer class' do
|
|
1069
1079
|
store.should_not be_nil
|
|
1070
1080
|
Moneta::Transformer::MarshalEscapeKeyMarshalValue.should_not be_nil
|
|
1071
1081
|
end}
|
|
1072
1082
|
},
|
|
1073
1083
|
'transformer_marshal_md5' => {
|
|
1074
|
-
:
|
|
1075
|
-
use :Transformer, :
|
|
1084
|
+
build: %{Moneta.build do
|
|
1085
|
+
use :Transformer, key: [:marshal, :md5], value: :marshal
|
|
1076
1086
|
adapter :Memory
|
|
1077
1087
|
end},
|
|
1078
|
-
:
|
|
1079
|
-
:
|
|
1088
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1089
|
+
tests: %{
|
|
1080
1090
|
it 'compile transformer class' do
|
|
1081
1091
|
store.should_not be_nil
|
|
1082
1092
|
Moneta::Transformer::MarshalMd5KeyMarshalValue.should_not be_nil
|
|
1083
1093
|
end}
|
|
1084
1094
|
},
|
|
1085
1095
|
'transformer_marshal_sha1' => {
|
|
1086
|
-
:
|
|
1087
|
-
use :Transformer, :
|
|
1096
|
+
build: %{Moneta.build do
|
|
1097
|
+
use :Transformer, key: [:marshal, :sha1], value: :marshal
|
|
1088
1098
|
adapter :Memory
|
|
1089
1099
|
end},
|
|
1090
|
-
:
|
|
1091
|
-
:
|
|
1100
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1101
|
+
tests: %{
|
|
1092
1102
|
it 'compile transformer class' do
|
|
1093
1103
|
store.should_not be_nil
|
|
1094
1104
|
Moneta::Transformer::MarshalSha1KeyMarshalValue.should_not be_nil
|
|
1095
1105
|
end}
|
|
1096
1106
|
},
|
|
1097
1107
|
'transformer_marshal_sha256' => {
|
|
1098
|
-
:
|
|
1099
|
-
use :Transformer, :
|
|
1108
|
+
build: %{Moneta.build do
|
|
1109
|
+
use :Transformer, key: [:marshal, :sha256], value: :marshal
|
|
1100
1110
|
adapter :Memory
|
|
1101
1111
|
end},
|
|
1102
|
-
:
|
|
1103
|
-
:
|
|
1112
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1113
|
+
tests: %{
|
|
1104
1114
|
it 'compile transformer class' do
|
|
1105
1115
|
store.should_not be_nil
|
|
1106
1116
|
Moneta::Transformer::MarshalSha256KeyMarshalValue.should_not be_nil
|
|
1107
1117
|
end}
|
|
1108
1118
|
},
|
|
1109
1119
|
'transformer_marshal_sha384' => {
|
|
1110
|
-
:
|
|
1111
|
-
use :Transformer, :
|
|
1120
|
+
build: %{Moneta.build do
|
|
1121
|
+
use :Transformer, key: [:marshal, :sha384], value: :marshal
|
|
1112
1122
|
adapter :Memory
|
|
1113
1123
|
end},
|
|
1114
|
-
:
|
|
1115
|
-
:
|
|
1124
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1125
|
+
tests: %{
|
|
1116
1126
|
it 'compile transformer class' do
|
|
1117
1127
|
store.should_not be_nil
|
|
1118
1128
|
Moneta::Transformer::MarshalSha384KeyMarshalValue.should_not be_nil
|
|
1119
1129
|
end}
|
|
1120
1130
|
},
|
|
1121
1131
|
'transformer_marshal_sha512' => {
|
|
1122
|
-
:
|
|
1123
|
-
use :Transformer, :
|
|
1132
|
+
build: %{Moneta.build do
|
|
1133
|
+
use :Transformer, key: [:marshal, :sha512], value: :marshal
|
|
1124
1134
|
adapter :Memory
|
|
1125
1135
|
end},
|
|
1126
|
-
:
|
|
1127
|
-
:
|
|
1136
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1137
|
+
tests: %{
|
|
1128
1138
|
it 'compile transformer class' do
|
|
1129
1139
|
store.should_not be_nil
|
|
1130
1140
|
Moneta::Transformer::MarshalSha512KeyMarshalValue.should_not be_nil
|
|
1131
1141
|
end}
|
|
1132
1142
|
},
|
|
1133
1143
|
'transformer_marshal_rmd160' => {
|
|
1134
|
-
:
|
|
1135
|
-
use :Transformer, :
|
|
1144
|
+
build: %{Moneta.build do
|
|
1145
|
+
use :Transformer, key: [:marshal, :rmd160], value: :marshal
|
|
1136
1146
|
adapter :Memory
|
|
1137
1147
|
end},
|
|
1138
|
-
:
|
|
1139
|
-
:
|
|
1148
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1149
|
+
tests: %{
|
|
1140
1150
|
it 'compile transformer class' do
|
|
1141
1151
|
store.should_not be_nil
|
|
1142
1152
|
Moneta::Transformer::MarshalRmd160KeyMarshalValue.should_not be_nil
|
|
1143
1153
|
end}
|
|
1144
1154
|
},
|
|
1145
1155
|
'transformer_marshal_md5_spread' => {
|
|
1146
|
-
:
|
|
1147
|
-
use :Transformer, :
|
|
1156
|
+
build: %{Moneta.build do
|
|
1157
|
+
use :Transformer, key: [:marshal, :md5, :spread], value: :marshal
|
|
1148
1158
|
adapter :Memory
|
|
1149
1159
|
end},
|
|
1150
|
-
:
|
|
1151
|
-
:
|
|
1160
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1161
|
+
tests: %{
|
|
1152
1162
|
it 'compile transformer class' do
|
|
1153
1163
|
store.should_not be_nil
|
|
1154
1164
|
Moneta::Transformer::MarshalMd5SpreadKeyMarshalValue.should_not be_nil
|
|
1155
1165
|
end}
|
|
1156
1166
|
},
|
|
1157
1167
|
'transformer_marshal_city32' => {
|
|
1158
|
-
:
|
|
1159
|
-
use :Transformer, :
|
|
1168
|
+
build: %{Moneta.build do
|
|
1169
|
+
use :Transformer, key: [:marshal, :city32], value: :marshal
|
|
1160
1170
|
adapter :Memory
|
|
1161
1171
|
end},
|
|
1162
|
-
:
|
|
1163
|
-
:
|
|
1172
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1173
|
+
tests: %{
|
|
1164
1174
|
it 'compile transformer class' do
|
|
1165
1175
|
store.should_not be_nil
|
|
1166
1176
|
Moneta::Transformer::MarshalCity32KeyMarshalValue.should_not be_nil
|
|
1167
1177
|
end}
|
|
1168
1178
|
},
|
|
1169
1179
|
'transformer_marshal_city64' => {
|
|
1170
|
-
:
|
|
1171
|
-
use :Transformer, :
|
|
1180
|
+
build: %{Moneta.build do
|
|
1181
|
+
use :Transformer, key: [:marshal, :city64], value: :marshal
|
|
1172
1182
|
adapter :Memory
|
|
1173
1183
|
end},
|
|
1174
|
-
:
|
|
1175
|
-
:
|
|
1184
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1185
|
+
tests: %{
|
|
1176
1186
|
it 'compile transformer class' do
|
|
1177
1187
|
store.should_not be_nil
|
|
1178
1188
|
Moneta::Transformer::MarshalCity64KeyMarshalValue.should_not be_nil
|
|
1179
1189
|
end}
|
|
1180
1190
|
},
|
|
1181
1191
|
'transformer_marshal_city128' => {
|
|
1182
|
-
:
|
|
1183
|
-
use :Transformer, :
|
|
1192
|
+
build: %{Moneta.build do
|
|
1193
|
+
use :Transformer, key: [:marshal, :city128], value: :marshal
|
|
1184
1194
|
adapter :Memory
|
|
1185
1195
|
end},
|
|
1186
|
-
:
|
|
1187
|
-
:
|
|
1196
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1197
|
+
tests: %{
|
|
1188
1198
|
it 'compile transformer class' do
|
|
1189
1199
|
store.should_not be_nil
|
|
1190
1200
|
Moneta::Transformer::MarshalCity128KeyMarshalValue.should_not be_nil
|
|
1191
1201
|
end}
|
|
1192
1202
|
},
|
|
1193
1203
|
'transformer_marshal_truncate' => {
|
|
1194
|
-
:
|
|
1195
|
-
use :Transformer, :
|
|
1204
|
+
build: %{Moneta.build do
|
|
1205
|
+
use :Transformer, key: [:marshal, :truncate], value: :marshal, maxlen: 64
|
|
1196
1206
|
adapter :Memory
|
|
1197
1207
|
end},
|
|
1198
|
-
:
|
|
1199
|
-
:
|
|
1208
|
+
specs: STANDARD_SPECS.without_persist,
|
|
1209
|
+
tests: %{
|
|
1200
1210
|
it 'compile transformer class' do
|
|
1201
1211
|
store.should_not be_nil
|
|
1202
1212
|
Moneta::Transformer::MarshalTruncateKeyMarshalValue.should_not be_nil
|
|
1203
1213
|
end}
|
|
1204
1214
|
},
|
|
1205
1215
|
'adapter_activerecord' => {
|
|
1206
|
-
:
|
|
1207
|
-
:
|
|
1208
|
-
:
|
|
1216
|
+
build: "Moneta::Adapters::ActiveRecord.new(table: 'adapter_activerecord', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta', username: 'root' })",
|
|
1217
|
+
specs: ADAPTER_SPECS,
|
|
1218
|
+
tests: %{
|
|
1209
1219
|
it 'updates an existing key/value' do
|
|
1210
1220
|
store['foo/bar'] = '1'
|
|
1211
1221
|
store['foo/bar'] = '2'
|
|
1212
|
-
store.table.where(:
|
|
1222
|
+
store.table.where(k: 'foo/bar').count.should == 1
|
|
1213
1223
|
end
|
|
1214
1224
|
|
|
1215
1225
|
it 'supports different tables same database' do
|
|
1216
|
-
store1 = Moneta::Adapters::ActiveRecord.new(:
|
|
1217
|
-
store2 = Moneta::Adapters::ActiveRecord.new(:
|
|
1226
|
+
store1 = Moneta::Adapters::ActiveRecord.new(table: 'adapter_activerecord1', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta', username: 'root' })
|
|
1227
|
+
store2 = Moneta::Adapters::ActiveRecord.new(table: 'adapter_activerecord2', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta', username: 'root' })
|
|
1218
1228
|
|
|
1219
1229
|
store1['key'] = 'value1'
|
|
1220
1230
|
store2['key'] = 'value2'
|
|
@@ -1226,8 +1236,8 @@ it 'supports different tables same database' do
|
|
|
1226
1236
|
end
|
|
1227
1237
|
|
|
1228
1238
|
it 'supports different databases same table' do
|
|
1229
|
-
store1 = Moneta::Adapters::ActiveRecord.new(:
|
|
1230
|
-
store2 = Moneta::Adapters::ActiveRecord.new(:
|
|
1239
|
+
store1 = Moneta::Adapters::ActiveRecord.new(table: 'adapter_activerecord', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta_activerecord1', username: 'root' })
|
|
1240
|
+
store2 = Moneta::Adapters::ActiveRecord.new(table: 'adapter_activerecord', connection: { adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta_activerecord2', username: 'root' })
|
|
1231
1241
|
|
|
1232
1242
|
store1['key'] = 'value1'
|
|
1233
1243
|
store2['key'] = 'value2'
|
|
@@ -1239,51 +1249,51 @@ it 'supports different databases same table' do
|
|
|
1239
1249
|
end}
|
|
1240
1250
|
},
|
|
1241
1251
|
'adapter_activerecord_exisiting_connection' => {
|
|
1242
|
-
:
|
|
1243
|
-
:
|
|
1244
|
-
:
|
|
1252
|
+
preamble: "require 'active_record'\nActiveRecord::Base.establish_connection adapter: (defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'), database: 'moneta', username: 'root'\n",
|
|
1253
|
+
build: "Moneta::Adapters::ActiveRecord.new(table: 'adapter_activerecord_existing_connection')",
|
|
1254
|
+
specs: ADAPTER_SPECS
|
|
1245
1255
|
},
|
|
1246
1256
|
'adapter_client' => {
|
|
1247
|
-
:
|
|
1248
|
-
:
|
|
1249
|
-
:
|
|
1257
|
+
preamble: "start_server(Moneta::Adapters::Memory.new)\n",
|
|
1258
|
+
build: "Moneta::Adapters::Client.new",
|
|
1259
|
+
specs: ADAPTER_SPECS
|
|
1250
1260
|
},
|
|
1251
1261
|
'adapter_restclient' => {
|
|
1252
|
-
:
|
|
1253
|
-
:
|
|
1254
|
-
:
|
|
1262
|
+
preamble: "start_restserver\n",
|
|
1263
|
+
build: "Moneta::Adapters::RestClient.new(url: 'http://localhost:8808/moneta/')",
|
|
1264
|
+
specs: ADAPTER_SPECS.without_increment.without_create
|
|
1255
1265
|
},
|
|
1256
1266
|
'adapter_cassandra' => {
|
|
1257
|
-
:
|
|
1258
|
-
:
|
|
1267
|
+
build: "Moneta::Adapters::Cassandra.new(keyspace: 'adapter_cassandra')",
|
|
1268
|
+
specs: ADAPTER_SPECS.without_increment.without_create.with_native_expires
|
|
1259
1269
|
},
|
|
1260
1270
|
'adapter_cassandra_with_default_expires' => {
|
|
1261
|
-
:
|
|
1262
|
-
:
|
|
1271
|
+
build: %{Moneta::Adapters::Cassandra.new(keyspace: 'adapter_cassandra_with_default_expires', expires: 1)},
|
|
1272
|
+
specs: ADAPTER_SPECS.without_increment.without_create.with_native_expires.with_default_expires
|
|
1263
1273
|
},
|
|
1264
1274
|
'adapter_hbase' => {
|
|
1265
|
-
:
|
|
1266
|
-
:
|
|
1275
|
+
build: "Moneta::Adapters::HBase.new(table: 'adapter_hbase')",
|
|
1276
|
+
specs: ADAPTER_SPECS.without_create
|
|
1267
1277
|
},
|
|
1268
1278
|
'adapter_cookie' => {
|
|
1269
|
-
:
|
|
1270
|
-
:
|
|
1279
|
+
build: 'Moneta::Adapters::Cookie.new',
|
|
1280
|
+
specs: ADAPTER_SPECS.without_persist.returnsame
|
|
1271
1281
|
},
|
|
1272
1282
|
'adapter_couch' => {
|
|
1273
|
-
:
|
|
1274
|
-
:
|
|
1283
|
+
build: "Moneta::Adapters::Couch.new(db: 'adapter_couch')",
|
|
1284
|
+
specs: ADAPTER_SPECS.without_increment.simplevalues_only.without_path
|
|
1275
1285
|
},
|
|
1276
1286
|
'adapter_datamapper' => {
|
|
1277
|
-
:
|
|
1287
|
+
build: 'Moneta::Adapters::DataMapper.new(setup: "mysql://root:@localhost/moneta", table: "adapter_datamapper")',
|
|
1278
1288
|
# DataMapper needs default repository to be setup
|
|
1279
|
-
:
|
|
1280
|
-
:
|
|
1281
|
-
:
|
|
1289
|
+
preamble: "require 'dm-core'\nDataMapper.setup(:default, adapter: :in_memory)\n",
|
|
1290
|
+
specs: ADAPTER_SPECS.without_increment,
|
|
1291
|
+
tests: %q{
|
|
1282
1292
|
it 'does not cross contaminate when storing' do
|
|
1283
|
-
first = Moneta::Adapters::DataMapper.new(:
|
|
1293
|
+
first = Moneta::Adapters::DataMapper.new(setup: "mysql://root:@localhost/moneta", table: "datamapper_first")
|
|
1284
1294
|
first.clear
|
|
1285
1295
|
|
|
1286
|
-
second = Moneta::Adapters::DataMapper.new(:
|
|
1296
|
+
second = Moneta::Adapters::DataMapper.new(repository: :sample, setup: "mysql://root:@localhost/moneta", table: "datamapper_second")
|
|
1287
1297
|
second.clear
|
|
1288
1298
|
|
|
1289
1299
|
first['key'] = 'value'
|
|
@@ -1294,10 +1304,10 @@ it 'does not cross contaminate when storing' do
|
|
|
1294
1304
|
end
|
|
1295
1305
|
|
|
1296
1306
|
it 'does not cross contaminate when deleting' do
|
|
1297
|
-
first = Moneta::Adapters::DataMapper.new(:
|
|
1307
|
+
first = Moneta::Adapters::DataMapper.new(setup: "mysql://root:@localhost/moneta", table: "datamapper_first")
|
|
1298
1308
|
first.clear
|
|
1299
1309
|
|
|
1300
|
-
second = Moneta::Adapters::DataMapper.new(:
|
|
1310
|
+
second = Moneta::Adapters::DataMapper.new(repository: :sample, setup: "mysql://root:@localhost/moneta", table: "datamapper_second")
|
|
1301
1311
|
second.clear
|
|
1302
1312
|
|
|
1303
1313
|
first['key'] = 'value'
|
|
@@ -1310,73 +1320,73 @@ end
|
|
|
1310
1320
|
}
|
|
1311
1321
|
},
|
|
1312
1322
|
'adapter_dbm' => {
|
|
1313
|
-
:
|
|
1314
|
-
:
|
|
1323
|
+
build: 'Moneta::Adapters::DBM.new(file: File.join(make_tempdir, "adapter_dbm"))',
|
|
1324
|
+
specs: ADAPTER_SPECS.without_multiprocess
|
|
1315
1325
|
},
|
|
1316
1326
|
'adapter_tdb' => {
|
|
1317
|
-
:
|
|
1318
|
-
:
|
|
1327
|
+
build: 'Moneta::Adapters::TDB.new(file: File.join(make_tempdir, "adapter_tdb"))',
|
|
1328
|
+
specs: ADAPTER_SPECS.without_multiprocess
|
|
1319
1329
|
},
|
|
1320
1330
|
'adapter_daybreak' => {
|
|
1321
|
-
:
|
|
1322
|
-
:
|
|
1331
|
+
build: 'Moneta::Adapters::Daybreak.new(file: File.join(make_tempdir, "adapter_daybreak"))',
|
|
1332
|
+
specs: ADAPTER_SPECS.without_multiprocess.returnsame
|
|
1323
1333
|
},
|
|
1324
1334
|
'adapter_file' => {
|
|
1325
|
-
:
|
|
1326
|
-
:
|
|
1335
|
+
build: 'Moneta::Adapters::File.new(dir: File.join(make_tempdir, "adapter_file"))',
|
|
1336
|
+
specs: ADAPTER_SPECS
|
|
1327
1337
|
},
|
|
1328
1338
|
'adapter_fog' => {
|
|
1329
|
-
:
|
|
1330
|
-
:
|
|
1331
|
-
:
|
|
1332
|
-
:
|
|
1339
|
+
build: "Moneta::Adapters::Fog.new(aws_access_key_id: 'fake_access_key_id',
|
|
1340
|
+
aws_secret_access_key: 'fake_secret_access_key',
|
|
1341
|
+
provider: 'AWS',
|
|
1342
|
+
dir: 'adapter_fog')",
|
|
1333
1343
|
# Put Fog into testing mode
|
|
1334
|
-
:
|
|
1344
|
+
preamble: "require 'fog'\nFog.mock!\n",
|
|
1335
1345
|
# Fog returns same object in mocking mode (in-memory store)
|
|
1336
|
-
:
|
|
1346
|
+
specs: ADAPTER_SPECS.without_increment.without_create.returnsame
|
|
1337
1347
|
},
|
|
1338
1348
|
'adapter_gdbm' => {
|
|
1339
|
-
:
|
|
1340
|
-
:
|
|
1349
|
+
build: 'Moneta::Adapters::GDBM.new(file: File.join(make_tempdir, "adapter_gdbm"))',
|
|
1350
|
+
specs: ADAPTER_SPECS.without_multiprocess
|
|
1341
1351
|
},
|
|
1342
1352
|
'adapter_localmemcache' => {
|
|
1343
|
-
:
|
|
1344
|
-
:
|
|
1353
|
+
build: 'Moneta::Adapters::LocalMemCache.new(file: File.join(make_tempdir, "adapter_localmemcache"))',
|
|
1354
|
+
specs: ADAPTER_SPECS.without_increment.without_create
|
|
1345
1355
|
},
|
|
1346
1356
|
'adapter_memcached_dalli' => {
|
|
1347
|
-
:
|
|
1348
|
-
:
|
|
1357
|
+
build: 'Moneta::Adapters::MemcachedDalli.new(namespace: "adapter_memcached_dalli")',
|
|
1358
|
+
specs: ADAPTER_SPECS.with_native_expires
|
|
1349
1359
|
},
|
|
1350
1360
|
'adapter_memcached_dalli_with_default_expires' => {
|
|
1351
|
-
:
|
|
1352
|
-
:
|
|
1361
|
+
build: %{Moneta::Adapters::MemcachedDalli.new(expires: 1)},
|
|
1362
|
+
specs: ADAPTER_SPECS.with_native_expires.with_default_expires
|
|
1353
1363
|
},
|
|
1354
1364
|
'adapter_memcached_native' => {
|
|
1355
|
-
:
|
|
1356
|
-
:
|
|
1365
|
+
build: 'Moneta::Adapters::MemcachedNative.new(namespace: "adapter_memcached_native")',
|
|
1366
|
+
specs: ADAPTER_SPECS.with_native_expires
|
|
1357
1367
|
},
|
|
1358
1368
|
'adapter_memcached_native_with_default_expires' => {
|
|
1359
|
-
:
|
|
1360
|
-
:
|
|
1369
|
+
build: %{Moneta::Adapters::MemcachedNative.new(expires: 1)},
|
|
1370
|
+
specs: ADAPTER_SPECS.with_native_expires.with_default_expires
|
|
1361
1371
|
},
|
|
1362
1372
|
'adapter_memcached' => {
|
|
1363
|
-
:
|
|
1364
|
-
:
|
|
1373
|
+
build: 'Moneta::Adapters::Memcached.new(namespace: "adapter_memcached")',
|
|
1374
|
+
specs: ADAPTER_SPECS.with_native_expires
|
|
1365
1375
|
},
|
|
1366
1376
|
'adapter_memcached_with_default_expires' => {
|
|
1367
|
-
:
|
|
1368
|
-
:
|
|
1377
|
+
build: %{Moneta::Adapters::Memcached.new(expires: 1)},
|
|
1378
|
+
specs: ADAPTER_SPECS.with_native_expires.with_default_expires
|
|
1369
1379
|
},
|
|
1370
1380
|
'adapter_memory' => {
|
|
1371
|
-
:
|
|
1372
|
-
:
|
|
1381
|
+
build: 'Moneta::Adapters::Memory.new',
|
|
1382
|
+
specs: STANDARD_SPECS.without_transform.returnsame.without_persist
|
|
1373
1383
|
},
|
|
1374
1384
|
'adapter_lruhash' => {
|
|
1375
|
-
:
|
|
1376
|
-
:
|
|
1377
|
-
:
|
|
1385
|
+
build: 'Moneta::Adapters::LRUHash.new',
|
|
1386
|
+
specs: ADAPTER_SPECS.without_persist.returnsame,
|
|
1387
|
+
tests: %{
|
|
1378
1388
|
it 'deletes oldest' do
|
|
1379
|
-
store = Moneta::Adapters::LRUHash.new(:
|
|
1389
|
+
store = Moneta::Adapters::LRUHash.new(max_size: 10)
|
|
1380
1390
|
store[0] = 'y'
|
|
1381
1391
|
(1..1000).each do |i|
|
|
1382
1392
|
store[i] = 'x'
|
|
@@ -1390,87 +1400,110 @@ it 'deletes oldest' do
|
|
|
1390
1400
|
end}
|
|
1391
1401
|
},
|
|
1392
1402
|
'adapter_mongo' => {
|
|
1393
|
-
:
|
|
1394
|
-
:
|
|
1395
|
-
|
|
1403
|
+
build: 'Moneta::Adapters::Mongo.new(db: "adapter_mongo")',
|
|
1404
|
+
specs: ADAPTER_SPECS.with_native_expires.simplevalues_only
|
|
1405
|
+
},
|
|
1406
|
+
'adapter_mongo_with_default_expires' => {
|
|
1407
|
+
build: %{Moneta::Adapters::Mongo.new(expires: 1)},
|
|
1408
|
+
specs: ADAPTER_SPECS.with_expires.with_default_expires.simplevalues_only
|
|
1409
|
+
},
|
|
1410
|
+
'adapter_mongo_moped' => {
|
|
1411
|
+
build: 'Moneta::Adapters::MongoMoped.new(db: "adapter_mongo")',
|
|
1412
|
+
specs: ADAPTER_SPECS.with_native_expires.simplevalues_only,
|
|
1413
|
+
tests: %{
|
|
1396
1414
|
it 'automatically deletes expired document' do
|
|
1397
|
-
store.store('key', 'val', :
|
|
1415
|
+
store.store('key', 'val', expires: 5)
|
|
1416
|
+
store.instance_variable_get(:@collection).find('_id' => ::Moped::BSON::Binary.new(:generic, 'key')).one.should_not be_nil
|
|
1417
|
+
sleep 70 # Mongo needs up to 60 seconds
|
|
1418
|
+
store.instance_variable_get(:@collection).find('_id' => ::Moped::BSON::Binary.new(:generic, 'key')).one.should be_nil
|
|
1419
|
+
end}
|
|
1420
|
+
},
|
|
1421
|
+
'adapter_mongo_moped_with_default_expires' => {
|
|
1422
|
+
build: %{Moneta::Adapters::MongoMoped.new(expires: 1)},
|
|
1423
|
+
specs: ADAPTER_SPECS.with_expires.with_default_expires.simplevalues_only
|
|
1424
|
+
},
|
|
1425
|
+
'adapter_mongo_official' => {
|
|
1426
|
+
build: 'Moneta::Adapters::MongoOfficial.new(db: "adapter_mongo")',
|
|
1427
|
+
specs: ADAPTER_SPECS.with_native_expires.simplevalues_only,
|
|
1428
|
+
tests: %{
|
|
1429
|
+
it 'automatically deletes expired document' do
|
|
1430
|
+
store.store('key', 'val', expires: 5)
|
|
1398
1431
|
store.instance_variable_get(:@collection).find_one('_id' => ::BSON::Binary.new('key')).should_not be_nil
|
|
1399
1432
|
sleep 70 # Mongo needs up to 60 seconds
|
|
1400
1433
|
store.instance_variable_get(:@collection).find_one('_id' => ::BSON::Binary.new('key')).should be_nil
|
|
1401
1434
|
end}
|
|
1402
1435
|
},
|
|
1403
|
-
'
|
|
1404
|
-
:
|
|
1405
|
-
:
|
|
1436
|
+
'adapter_mongo_official_with_default_expires' => {
|
|
1437
|
+
build: %{Moneta::Adapters::MongoOfficial.new(expires: 1)},
|
|
1438
|
+
specs: ADAPTER_SPECS.with_expires.with_default_expires.simplevalues_only
|
|
1406
1439
|
},
|
|
1407
1440
|
'adapter_pstore' => {
|
|
1408
|
-
:
|
|
1409
|
-
:
|
|
1441
|
+
build: 'Moneta::Adapters::PStore.new(file: File.join(make_tempdir, "adapter_pstore"))',
|
|
1442
|
+
specs: STANDARD_SPECS.without_transform
|
|
1410
1443
|
},
|
|
1411
1444
|
'adapter_redis' => {
|
|
1412
|
-
:
|
|
1413
|
-
:
|
|
1445
|
+
build: 'Moneta::Adapters::Redis.new',
|
|
1446
|
+
specs: ADAPTER_SPECS.with_native_expires
|
|
1414
1447
|
},
|
|
1415
1448
|
'adapter_redis_with_default_expires' => {
|
|
1416
|
-
:
|
|
1417
|
-
:
|
|
1449
|
+
build: %{Moneta::Adapters::Redis.new(expires: 1)},
|
|
1450
|
+
specs: ADAPTER_SPECS.with_native_expires.with_default_expires
|
|
1418
1451
|
},
|
|
1419
1452
|
'adapter_riak' => {
|
|
1420
|
-
:
|
|
1421
|
-
:
|
|
1422
|
-
:
|
|
1453
|
+
build: 'Moneta::Adapters::Riak.new',
|
|
1454
|
+
options: ":bucket => 'adapter_riak'",
|
|
1455
|
+
specs: ADAPTER_SPECS.without_increment.without_create,
|
|
1423
1456
|
# We don't want Riak warnings in tests
|
|
1424
|
-
:
|
|
1457
|
+
preamble: "require 'riak'\n\nRiak.disable_list_keys_warnings = true\n\n"
|
|
1425
1458
|
},
|
|
1426
1459
|
'adapter_sdbm' => {
|
|
1427
|
-
:
|
|
1428
|
-
:
|
|
1460
|
+
build: 'Moneta::Adapters::SDBM.new(file: File.join(make_tempdir, "adapter_sdbm"))',
|
|
1461
|
+
specs: ADAPTER_SPECS.without_multiprocess.without_large
|
|
1429
1462
|
},
|
|
1430
1463
|
'adapter_lmdb' => {
|
|
1431
|
-
:
|
|
1432
|
-
:
|
|
1464
|
+
build: 'Moneta::Adapters::LMDB.new(dir: File.join(make_tempdir, "adapter_lmdb"))',
|
|
1465
|
+
specs: ADAPTER_SPECS.without_concurrent
|
|
1433
1466
|
},
|
|
1434
1467
|
'adapter_lmdb_with_db' => {
|
|
1435
|
-
:
|
|
1436
|
-
:
|
|
1468
|
+
build: 'Moneta::Adapters::LMDB.new(dir: File.join(make_tempdir, "adapter_lmdb"), db: "adapter_lmdb_with_db")',
|
|
1469
|
+
specs: ADAPTER_SPECS.without_concurrent
|
|
1437
1470
|
},
|
|
1438
1471
|
'adapter_leveldb' => {
|
|
1439
|
-
:
|
|
1440
|
-
:
|
|
1472
|
+
build: 'Moneta::Adapters::LevelDB.new(dir: File.join(make_tempdir, "adapter_leveldb"))',
|
|
1473
|
+
specs: ADAPTER_SPECS.without_multiprocess
|
|
1441
1474
|
},
|
|
1442
1475
|
'adapter_sequel' => {
|
|
1443
|
-
:
|
|
1444
|
-
:
|
|
1476
|
+
build: 'Moneta::Adapters::Sequel.new(db: (defined?(JRUBY_VERSION) ? "jdbc:mysql://localhost/moneta?user=root" : "mysql2://root:@localhost/moneta"), table: "adapter_sequel")',
|
|
1477
|
+
specs: ADAPTER_SPECS
|
|
1445
1478
|
},
|
|
1446
1479
|
'adapter_sqlite' => {
|
|
1447
|
-
:
|
|
1448
|
-
:
|
|
1480
|
+
build: 'Moneta::Adapters::Sqlite.new(file: File.join(make_tempdir, "adapter_sqlite"))',
|
|
1481
|
+
specs: ADAPTER_SPECS.without_concurrent
|
|
1449
1482
|
},
|
|
1450
1483
|
'adapter_kyotocabinet' => {
|
|
1451
|
-
:
|
|
1452
|
-
:
|
|
1484
|
+
build: 'Moneta::Adapters::KyotoCabinet.new(file: File.join(make_tempdir, "adapter_kyotocabinet.kch"))',
|
|
1485
|
+
specs: ADAPTER_SPECS.without_multiprocess
|
|
1453
1486
|
},
|
|
1454
1487
|
'adapter_tokyocabinet_bdb' => {
|
|
1455
|
-
:
|
|
1456
|
-
:
|
|
1488
|
+
build: 'Moneta::Adapters::TokyoCabinet.new(file: File.join(make_tempdir, "adapter_tokyocabinet_bdb"), type: :bdb)',
|
|
1489
|
+
specs: ADAPTER_SPECS.without_multiprocess
|
|
1457
1490
|
},
|
|
1458
1491
|
'adapter_tokyocabinet_hdb' => {
|
|
1459
|
-
:
|
|
1460
|
-
:
|
|
1492
|
+
build: 'Moneta::Adapters::TokyoCabinet.new(file: File.join(make_tempdir, "adapter_tokyocabinet_hdb"), type: :hdb)',
|
|
1493
|
+
specs: ADAPTER_SPECS.without_multiprocess
|
|
1461
1494
|
},
|
|
1462
1495
|
'adapter_tokyotyrant' => {
|
|
1463
|
-
:
|
|
1464
|
-
:
|
|
1496
|
+
build: 'Moneta::Adapters::TokyoTyrant.new',
|
|
1497
|
+
specs: ADAPTER_SPECS
|
|
1465
1498
|
},
|
|
1466
1499
|
'adapter_yaml' => {
|
|
1467
|
-
:
|
|
1468
|
-
:
|
|
1500
|
+
build: 'Moneta::Adapters::YAML.new(file: File.join(make_tempdir, "adapter_yaml"))',
|
|
1501
|
+
specs: STANDARD_SPECS.simplevalues_only.simplekeys_only.without_transform.without_concurrent
|
|
1469
1502
|
},
|
|
1470
1503
|
'mutex' => {
|
|
1471
|
-
:
|
|
1472
|
-
:
|
|
1473
|
-
:
|
|
1504
|
+
store: :Memory,
|
|
1505
|
+
specs: Specs.new,
|
|
1506
|
+
tests: %{
|
|
1474
1507
|
it 'should have #lock' do
|
|
1475
1508
|
mutex = Moneta::Mutex.new(store, 'mutex')
|
|
1476
1509
|
mutex.lock.should be_true
|
|
@@ -1525,9 +1558,9 @@ end
|
|
|
1525
1558
|
}
|
|
1526
1559
|
},
|
|
1527
1560
|
'semaphore' => {
|
|
1528
|
-
:
|
|
1529
|
-
:
|
|
1530
|
-
:
|
|
1561
|
+
store: :Memory,
|
|
1562
|
+
specs: Specs.new,
|
|
1563
|
+
tests: %{
|
|
1531
1564
|
it 'should have #lock' do
|
|
1532
1565
|
mutex = Moneta::Semaphore.new(store, 'semaphore')
|
|
1533
1566
|
mutex.lock.should be_true
|
|
@@ -1595,17 +1628,17 @@ end
|
|
|
1595
1628
|
}
|
|
1596
1629
|
},
|
|
1597
1630
|
'optionmerger' => {
|
|
1598
|
-
:
|
|
1599
|
-
:
|
|
1600
|
-
:
|
|
1631
|
+
store: :Memory,
|
|
1632
|
+
specs: Specs.new,
|
|
1633
|
+
tests: %{
|
|
1601
1634
|
it '#with should return OptionMerger' do
|
|
1602
|
-
options = {:
|
|
1635
|
+
options = {optionname: :optionvalue}
|
|
1603
1636
|
merger = store.with(options)
|
|
1604
1637
|
merger.should be_instance_of(Moneta::OptionMerger)
|
|
1605
1638
|
end
|
|
1606
1639
|
|
|
1607
1640
|
it 'saves default options' do
|
|
1608
|
-
options = {:
|
|
1641
|
+
options = {optionname: :optionvalue}
|
|
1609
1642
|
merger = store.with(options)
|
|
1610
1643
|
Moneta::OptionMerger::METHODS.each do |method|
|
|
1611
1644
|
merger.default_options[method].should equal(options)
|
|
@@ -1615,42 +1648,42 @@ end
|
|
|
1615
1648
|
PREFIX = [['alpha', nil], ['beta', nil], ['alpha', 'beta']]
|
|
1616
1649
|
|
|
1617
1650
|
it 'merges options' do
|
|
1618
|
-
merger = store.with(:
|
|
1651
|
+
merger = store.with(opt1: :val1, opt2: :val2).with(opt2: :overwrite, opt3: :val3)
|
|
1619
1652
|
Moneta::OptionMerger::METHODS.each do |method|
|
|
1620
|
-
merger.default_options[method].should == {:
|
|
1653
|
+
merger.default_options[method].should == {opt1: :val1, opt2: :overwrite, opt3: :val3}
|
|
1621
1654
|
end
|
|
1622
1655
|
end
|
|
1623
1656
|
|
|
1624
1657
|
it 'merges options only for some methods' do
|
|
1625
1658
|
PREFIX.each do |(alpha,beta)|
|
|
1626
|
-
options = {:
|
|
1627
|
-
merger = store.with(options).with(:
|
|
1659
|
+
options = {opt1: :val1, opt2: :val2, prefix: alpha}
|
|
1660
|
+
merger = store.with(options).with(opt2: :overwrite, opt3: :val3, prefix: beta, only: :clear)
|
|
1628
1661
|
(Moneta::OptionMerger::METHODS - [:clear]).each do |method|
|
|
1629
1662
|
merger.default_options[method].should equal(options)
|
|
1630
1663
|
end
|
|
1631
|
-
merger.default_options[:clear].should == {:
|
|
1664
|
+
merger.default_options[:clear].should == {opt1: :val1, opt2: :overwrite, opt3: :val3, prefix: "\#{alpha}\#{beta}"}
|
|
1632
1665
|
|
|
1633
|
-
merger = store.with(options).with(:
|
|
1666
|
+
merger = store.with(options).with(opt2: :overwrite, opt3: :val3, prefix: beta, only: [:load, :store])
|
|
1634
1667
|
(Moneta::OptionMerger::METHODS - [:load, :store]).each do |method|
|
|
1635
1668
|
merger.default_options[method].should equal(options)
|
|
1636
1669
|
end
|
|
1637
|
-
merger.default_options[:load].should == {:
|
|
1638
|
-
merger.default_options[:store].should == {:
|
|
1670
|
+
merger.default_options[:load].should == {opt1: :val1, opt2: :overwrite, opt3: :val3, prefix: "\#{alpha}\#{beta}"}
|
|
1671
|
+
merger.default_options[:store].should == {opt1: :val1, opt2: :overwrite, opt3: :val3, prefix: "\#{alpha}\#{beta}"}
|
|
1639
1672
|
end
|
|
1640
1673
|
end
|
|
1641
1674
|
|
|
1642
1675
|
it 'merges options except for some methods' do
|
|
1643
1676
|
PREFIX.each do |(alpha,beta)|
|
|
1644
|
-
options = {:
|
|
1645
|
-
merger = store.with(options).with(:
|
|
1677
|
+
options = {opt1: :val1, opt2: :val2, prefix: alpha}
|
|
1678
|
+
merger = store.with(options).with(opt2: :overwrite, opt3: :val3, except: :clear, prefix: beta)
|
|
1646
1679
|
(Moneta::OptionMerger::METHODS - [:clear]).each do |method|
|
|
1647
|
-
merger.default_options[method].should == {:
|
|
1680
|
+
merger.default_options[method].should == {opt1: :val1, opt2: :overwrite, opt3: :val3, prefix: "\#{alpha}\#{beta}"}
|
|
1648
1681
|
end
|
|
1649
1682
|
merger.default_options[:clear].should equal(options)
|
|
1650
1683
|
|
|
1651
|
-
merger = store.with(options).with(:
|
|
1684
|
+
merger = store.with(options).with(opt2: :overwrite, opt3: :val3, prefix: beta, except: [:load, :store])
|
|
1652
1685
|
(Moneta::OptionMerger::METHODS - [:load, :store]).each do |method|
|
|
1653
|
-
merger.default_options[method].should == {:
|
|
1686
|
+
merger.default_options[method].should == {opt1: :val1, opt2: :overwrite, opt3: :val3, prefix: "\#{alpha}\#{beta}"}
|
|
1654
1687
|
end
|
|
1655
1688
|
merger.default_options[:load].should equal(options)
|
|
1656
1689
|
merger.default_options[:store].should equal(options)
|
|
@@ -1658,29 +1691,29 @@ it 'merges options except for some methods' do
|
|
|
1658
1691
|
end
|
|
1659
1692
|
|
|
1660
1693
|
it 'has method #raw' do
|
|
1661
|
-
store.raw.default_options.should == {:
|
|
1694
|
+
store.raw.default_options.should == {store:{raw:true},create:{raw:true},load:{raw:true},delete:{raw:true}}
|
|
1662
1695
|
store.raw.should equal(store.raw.raw)
|
|
1663
1696
|
end
|
|
1664
1697
|
|
|
1665
1698
|
it 'has method #expires' do
|
|
1666
|
-
store.expires(10).default_options.should == {:
|
|
1699
|
+
store.expires(10).default_options.should == {store:{expires:10},create:{expires:10},increment:{expires:10}}
|
|
1667
1700
|
end
|
|
1668
1701
|
|
|
1669
1702
|
it 'has method #prefix' do
|
|
1670
|
-
store.prefix('a').default_options.should == {:
|
|
1671
|
-
:
|
|
1703
|
+
store.prefix('a').default_options.should == {store:{prefix:'a'},load:{prefix:'a'},create:{prefix:'a'},
|
|
1704
|
+
delete:{prefix:'a'},key?: {prefix:'a'},increment:{prefix:'a'}}
|
|
1672
1705
|
|
|
1673
|
-
store.prefix('a').prefix('b').default_options.should == {:
|
|
1674
|
-
:
|
|
1706
|
+
store.prefix('a').prefix('b').default_options.should == {store:{prefix:'ab'},load:{prefix:'ab'},create:{prefix:'ab'},
|
|
1707
|
+
delete:{prefix:'ab'},key?: {prefix:'ab'},increment:{prefix:'ab'}}
|
|
1675
1708
|
|
|
1676
|
-
store.raw.prefix('b').default_options.should == {:
|
|
1709
|
+
store.raw.prefix('b').default_options.should == {store:{raw:true,prefix:'b'},load:{raw:true,prefix:'b'},create:{raw:true,prefix:'b'},delete:{raw:true,prefix:'b'},key?: {prefix:'b'},increment:{prefix:'b'}}
|
|
1677
1710
|
|
|
1678
|
-
store.prefix('a').raw.default_options.should == {:
|
|
1711
|
+
store.prefix('a').raw.default_options.should == {store:{raw:true,prefix:'a'},load:{raw:true,prefix:'a'},create:{raw:true,prefix:'a'},delete:{raw:true,prefix:'a'},key?: {prefix:'a'},increment:{prefix:'a'}}
|
|
1679
1712
|
end
|
|
1680
1713
|
|
|
1681
1714
|
it 'supports adding proxis using #with' do
|
|
1682
|
-
compressed_store = store.with(:
|
|
1683
|
-
use :Transformer, :
|
|
1715
|
+
compressed_store = store.with(prefix: 'compressed') do
|
|
1716
|
+
use :Transformer, value: :zlib
|
|
1684
1717
|
end
|
|
1685
1718
|
store['key'] = 'uncompressed value'
|
|
1686
1719
|
compressed_store['key'] = 'compressed value'
|
|
@@ -1768,7 +1801,7 @@ it 'fetches a key with a block with fetch, if the key is not available' do
|
|
|
1768
1801
|
end
|
|
1769
1802
|
|
|
1770
1803
|
it 'accepts frozen options' do
|
|
1771
|
-
options = {:
|
|
1804
|
+
options = {option1: 1, options2: 2}
|
|
1772
1805
|
options.freeze
|
|
1773
1806
|
store.key?(#{key1}, options).should be_false
|
|
1774
1807
|
store.load(#{key1}, options).should be_nil
|
|
@@ -1902,8 +1935,8 @@ SPECS['multiprocess'] = %{it 'supports access by multiple instances/processes' d
|
|
|
1902
1935
|
store2.close
|
|
1903
1936
|
end}
|
|
1904
1937
|
|
|
1905
|
-
SPECS['expires'] = %{it 'supports expires on store and []', :
|
|
1906
|
-
store.store('key1', 'val1', :
|
|
1938
|
+
SPECS['expires'] = %{it 'supports expires on store and []', retry: 3 do
|
|
1939
|
+
store.store('key1', 'val1', expires: 3)
|
|
1907
1940
|
store['key1'].should == 'val1'
|
|
1908
1941
|
sleep 1
|
|
1909
1942
|
store['key1'].should == 'val1'
|
|
@@ -1912,14 +1945,14 @@ SPECS['expires'] = %{it 'supports expires on store and []', :retry => 3 do
|
|
|
1912
1945
|
end
|
|
1913
1946
|
|
|
1914
1947
|
it 'supports strict expires on store and []' do
|
|
1915
|
-
store.store('key1', 'val1', :
|
|
1948
|
+
store.store('key1', 'val1', expires: 2)
|
|
1916
1949
|
store['key1'].should == 'val1'
|
|
1917
1950
|
sleep 3 # Sleep 3 seconds because after 2 seconds the value can still exist!
|
|
1918
1951
|
store['key1'].should be_nil
|
|
1919
1952
|
end
|
|
1920
1953
|
|
|
1921
|
-
it 'supports expires on store and fetch', :
|
|
1922
|
-
store.store('key1', 'val1', :
|
|
1954
|
+
it 'supports expires on store and fetch', retry: 3 do
|
|
1955
|
+
store.store('key1', 'val1', expires: 3)
|
|
1923
1956
|
store.fetch('key1').should == 'val1'
|
|
1924
1957
|
sleep 1
|
|
1925
1958
|
store.fetch('key1').should == 'val1'
|
|
@@ -1928,28 +1961,28 @@ it 'supports expires on store and fetch', :retry => 3 do
|
|
|
1928
1961
|
end
|
|
1929
1962
|
|
|
1930
1963
|
it 'supports strict expires on store and fetch' do
|
|
1931
|
-
store.store('key1', 'val1', :
|
|
1964
|
+
store.store('key1', 'val1', expires: 2)
|
|
1932
1965
|
store.fetch('key1').should == 'val1'
|
|
1933
1966
|
sleep 3 # Sleep 3 seconds because after 2 seconds the value can still exist!
|
|
1934
1967
|
store.fetch('key1').should be_nil
|
|
1935
1968
|
end
|
|
1936
1969
|
|
|
1937
1970
|
it 'supports 0 as no-expires on store and []' do
|
|
1938
|
-
store.store('key1', 'val1', :
|
|
1971
|
+
store.store('key1', 'val1', expires: 0)
|
|
1939
1972
|
store['key1'].should == 'val1'
|
|
1940
1973
|
sleep 2
|
|
1941
1974
|
store['key1'].should == 'val1'
|
|
1942
1975
|
end
|
|
1943
1976
|
|
|
1944
1977
|
it 'supports false as no-expires on store and []' do
|
|
1945
|
-
store.store('key1', 'val1', :
|
|
1978
|
+
store.store('key1', 'val1', expires: false)
|
|
1946
1979
|
store['key1'].should == 'val1'
|
|
1947
1980
|
sleep 2
|
|
1948
1981
|
store['key1'].should == 'val1'
|
|
1949
1982
|
end
|
|
1950
1983
|
|
|
1951
|
-
it 'supports expires on store and load', :
|
|
1952
|
-
store.store('key1', 'val1', :
|
|
1984
|
+
it 'supports expires on store and load', retry: 3 do
|
|
1985
|
+
store.store('key1', 'val1', expires: 3)
|
|
1953
1986
|
store.load('key1').should == 'val1'
|
|
1954
1987
|
sleep 1
|
|
1955
1988
|
store.load('key1').should == 'val1'
|
|
@@ -1958,14 +1991,14 @@ it 'supports expires on store and load', :retry => 3 do
|
|
|
1958
1991
|
end
|
|
1959
1992
|
|
|
1960
1993
|
it 'supports strict expires on store and load' do
|
|
1961
|
-
store.store('key1', 'val1', :
|
|
1994
|
+
store.store('key1', 'val1', expires: 2)
|
|
1962
1995
|
store.load('key1').should == 'val1'
|
|
1963
1996
|
sleep 3 # Sleep 3 seconds because after 2 seconds the value can still exist!
|
|
1964
1997
|
store.load('key1').should be_nil
|
|
1965
1998
|
end
|
|
1966
1999
|
|
|
1967
|
-
it 'supports expires on store and #key?', :
|
|
1968
|
-
store.store('key1', 'val1', :
|
|
2000
|
+
it 'supports expires on store and #key?', retry: 3 do
|
|
2001
|
+
store.store('key1', 'val1', expires: 3)
|
|
1969
2002
|
store.key?('key1').should be_true
|
|
1970
2003
|
sleep 1
|
|
1971
2004
|
store.key?('key1').should be_true
|
|
@@ -1974,17 +2007,17 @@ it 'supports expires on store and #key?', :retry => 3 do
|
|
|
1974
2007
|
end
|
|
1975
2008
|
|
|
1976
2009
|
it 'supports strict expires on store and #key?' do
|
|
1977
|
-
store.store('key1', 'val1', :
|
|
2010
|
+
store.store('key1', 'val1', expires: 2)
|
|
1978
2011
|
store.key?('key1').should be_true
|
|
1979
2012
|
sleep 3 # Sleep 3 seconds because after 2 seconds the value can still exist!
|
|
1980
2013
|
store.key?('key1').should be_false
|
|
1981
2014
|
end
|
|
1982
2015
|
|
|
1983
|
-
it 'supports updating the expiration time in load', :
|
|
1984
|
-
store.store('key2', 'val2', :
|
|
2016
|
+
it 'supports updating the expiration time in load', retry: 3 do
|
|
2017
|
+
store.store('key2', 'val2', expires: 3)
|
|
1985
2018
|
store['key2'].should == 'val2'
|
|
1986
2019
|
sleep 1
|
|
1987
|
-
store.load('key2', :
|
|
2020
|
+
store.load('key2', expires: 5).should == 'val2'
|
|
1988
2021
|
store['key2'].should == 'val2'
|
|
1989
2022
|
sleep 3
|
|
1990
2023
|
store['key2'].should == 'val2'
|
|
@@ -1993,24 +2026,24 @@ it 'supports updating the expiration time in load', :retry => 3 do
|
|
|
1993
2026
|
end
|
|
1994
2027
|
|
|
1995
2028
|
it 'supports 0 as no-expires in load' do
|
|
1996
|
-
store.store('key1', 'val1', :
|
|
1997
|
-
store.load('key1', :
|
|
2029
|
+
store.store('key1', 'val1', expires: 2)
|
|
2030
|
+
store.load('key1', expires: 0).should == 'val1'
|
|
1998
2031
|
sleep 3
|
|
1999
2032
|
store.load('key1').should == 'val1'
|
|
2000
2033
|
end
|
|
2001
2034
|
|
|
2002
2035
|
it 'supports false as no-expires in load' do
|
|
2003
|
-
store.store('key1', 'val1', :
|
|
2004
|
-
store.load('key1', :
|
|
2036
|
+
store.store('key1', 'val1', expires: 2)
|
|
2037
|
+
store.load('key1', expires: false).should == 'val1'
|
|
2005
2038
|
sleep 3
|
|
2006
2039
|
store.load('key1').should == 'val1'
|
|
2007
2040
|
end
|
|
2008
2041
|
|
|
2009
|
-
it 'supports updating the expiration time in #key?', :
|
|
2010
|
-
store.store('key2', 'val2', :
|
|
2042
|
+
it 'supports updating the expiration time in #key?', retry: 3 do
|
|
2043
|
+
store.store('key2', 'val2', expires: 3)
|
|
2011
2044
|
store['key2'].should == 'val2'
|
|
2012
2045
|
sleep 1
|
|
2013
|
-
store.key?('key2', :
|
|
2046
|
+
store.key?('key2', expires: 5).should be_true
|
|
2014
2047
|
store['key2'].should == 'val2'
|
|
2015
2048
|
sleep 3
|
|
2016
2049
|
store['key2'].should == 'val2'
|
|
@@ -2019,24 +2052,24 @@ it 'supports updating the expiration time in #key?', :retry => 3 do
|
|
|
2019
2052
|
end
|
|
2020
2053
|
|
|
2021
2054
|
it 'supports 0 as no-expires in #key?' do
|
|
2022
|
-
store.store('key1', 'val1', :
|
|
2023
|
-
store.key?('key1', :
|
|
2055
|
+
store.store('key1', 'val1', expires: 2)
|
|
2056
|
+
store.key?('key1', expires: 0).should be_true
|
|
2024
2057
|
sleep 3
|
|
2025
2058
|
store['key1'].should == 'val1'
|
|
2026
2059
|
end
|
|
2027
2060
|
|
|
2028
2061
|
it 'supports false as no-expires in #key?' do
|
|
2029
|
-
store.store('key1', 'val1', :
|
|
2030
|
-
store.key?('key1', :
|
|
2062
|
+
store.store('key1', 'val1', expires: 2)
|
|
2063
|
+
store.key?('key1', expires: false ).should be_true
|
|
2031
2064
|
sleep 3
|
|
2032
2065
|
store['key1'].should == 'val1'
|
|
2033
2066
|
end
|
|
2034
2067
|
|
|
2035
|
-
it 'supports updating the expiration time in fetch', :
|
|
2036
|
-
store.store('key1', 'val1', :
|
|
2068
|
+
it 'supports updating the expiration time in fetch', retry: 3 do
|
|
2069
|
+
store.store('key1', 'val1', expires: 3)
|
|
2037
2070
|
store['key1'].should == 'val1'
|
|
2038
2071
|
sleep 1
|
|
2039
|
-
store.fetch('key1', nil, :
|
|
2072
|
+
store.fetch('key1', nil, expires: 5).should == 'val1'
|
|
2040
2073
|
store['key1'].should == 'val1'
|
|
2041
2074
|
sleep 3
|
|
2042
2075
|
store['key1'].should == 'val1'
|
|
@@ -2045,28 +2078,28 @@ it 'supports updating the expiration time in fetch', :retry => 3 do
|
|
|
2045
2078
|
end
|
|
2046
2079
|
|
|
2047
2080
|
it 'supports 0 as no-expires in fetch' do
|
|
2048
|
-
store.store('key1', 'val1', :
|
|
2049
|
-
store.fetch('key1', nil, :
|
|
2081
|
+
store.store('key1', 'val1', expires: 2)
|
|
2082
|
+
store.fetch('key1', nil, expires: 0).should == 'val1'
|
|
2050
2083
|
sleep 3
|
|
2051
2084
|
store.load('key1').should == 'val1'
|
|
2052
2085
|
end
|
|
2053
2086
|
|
|
2054
2087
|
it 'supports false as no-expires in fetch' do
|
|
2055
|
-
store.store('key1', 'val1', :
|
|
2056
|
-
store.fetch('key1', nil, :
|
|
2088
|
+
store.store('key1', 'val1', expires: 2)
|
|
2089
|
+
store.fetch('key1', nil, expires: false).should == 'val1'
|
|
2057
2090
|
sleep 3
|
|
2058
2091
|
store.load('key1').should == 'val1'
|
|
2059
2092
|
end
|
|
2060
2093
|
|
|
2061
2094
|
it 'strictly respects expires in delete' do
|
|
2062
|
-
store.store('key2', 'val2', :
|
|
2095
|
+
store.store('key2', 'val2', expires: 2)
|
|
2063
2096
|
store['key2'].should == 'val2'
|
|
2064
2097
|
sleep 3 # Sleep 3 seconds because after 2 seconds the value can still exist!
|
|
2065
2098
|
store.delete('key2').should be_nil
|
|
2066
2099
|
end
|
|
2067
2100
|
|
|
2068
|
-
it 'respects expires in delete', :
|
|
2069
|
-
store.store('key2', 'val2', :
|
|
2101
|
+
it 'respects expires in delete', retry: 3 do
|
|
2102
|
+
store.store('key2', 'val2', expires: 3)
|
|
2070
2103
|
store['key2'].should == 'val2'
|
|
2071
2104
|
sleep 1
|
|
2072
2105
|
store['key2'].should == 'val2'
|
|
@@ -2074,8 +2107,8 @@ it 'respects expires in delete', :retry => 3 do
|
|
|
2074
2107
|
store.delete('key2').should be_nil
|
|
2075
2108
|
end
|
|
2076
2109
|
|
|
2077
|
-
it 'supports the #expires syntactic sugar', :
|
|
2078
|
-
store.store('persistent_key', 'persistent_value', :
|
|
2110
|
+
it 'supports the #expires syntactic sugar', retry: 3 do
|
|
2111
|
+
store.store('persistent_key', 'persistent_value', expires: 0)
|
|
2079
2112
|
store.expires(1).store('key2', 'val2')
|
|
2080
2113
|
store['key2'].should == 'val2'
|
|
2081
2114
|
sleep 2
|
|
@@ -2084,32 +2117,32 @@ it 'supports the #expires syntactic sugar', :retry => 3 do
|
|
|
2084
2117
|
end
|
|
2085
2118
|
|
|
2086
2119
|
it 'supports false as no-expires on store and []' do
|
|
2087
|
-
store.store('key1', 'val1', :
|
|
2120
|
+
store.store('key1', 'val1', expires: false)
|
|
2088
2121
|
store['key1'].should == 'val1'
|
|
2089
2122
|
sleep 2
|
|
2090
2123
|
store['key1'].should == 'val1'
|
|
2091
2124
|
end
|
|
2092
2125
|
|
|
2093
|
-
it 'does not update the expiration time in #key? when not asked to do so', :
|
|
2094
|
-
store.store('key1', 'val1', :
|
|
2126
|
+
it 'does not update the expiration time in #key? when not asked to do so', retry: 3 do
|
|
2127
|
+
store.store('key1', 'val1', expires: 1)
|
|
2095
2128
|
store.key?('key1').should be_true
|
|
2096
|
-
store.key?('key1', :
|
|
2129
|
+
store.key?('key1', expires: nil).should be_true
|
|
2097
2130
|
sleep 2
|
|
2098
2131
|
store.key?('key1').should be_false
|
|
2099
2132
|
end
|
|
2100
2133
|
|
|
2101
|
-
it 'does not update the expiration time in fetch when not asked to do so', :
|
|
2102
|
-
store.store('key1', 'val1', :
|
|
2134
|
+
it 'does not update the expiration time in fetch when not asked to do so', retry: 3 do
|
|
2135
|
+
store.store('key1', 'val1', expires: 1)
|
|
2103
2136
|
store.fetch('key1').should == 'val1'
|
|
2104
|
-
store.fetch('key1', :
|
|
2137
|
+
store.fetch('key1', expires: nil).should == 'val1'
|
|
2105
2138
|
sleep 2
|
|
2106
2139
|
store.fetch('key1').should be_nil
|
|
2107
2140
|
end
|
|
2108
2141
|
|
|
2109
|
-
it 'does not update the expiration time in load when not asked to do so', :
|
|
2110
|
-
store.store('key1', 'val1', :
|
|
2142
|
+
it 'does not update the expiration time in load when not asked to do so', retry: 3 do
|
|
2143
|
+
store.store('key1', 'val1', expires: 1)
|
|
2111
2144
|
store.load('key1').should == 'val1'
|
|
2112
|
-
store.load('key1', :
|
|
2145
|
+
store.load('key1', expires: nil).should == 'val1'
|
|
2113
2146
|
sleep 2
|
|
2114
2147
|
store.load('key1').should be_nil
|
|
2115
2148
|
end}
|
|
@@ -2142,10 +2175,10 @@ SPECS['concurrent_increment'] = %{def increment_thread(name)
|
|
|
2142
2175
|
s = new_store
|
|
2143
2176
|
100.times do |i|
|
|
2144
2177
|
100.times do |j|
|
|
2145
|
-
s.increment("counter\#{j}", 1, :
|
|
2178
|
+
s.increment("counter\#{j}", 1, expires: false)
|
|
2146
2179
|
Thread.pass if rand(1000) >= 995
|
|
2147
2180
|
end
|
|
2148
|
-
s.store("\#{name}\#{i}", i.to_s, :
|
|
2181
|
+
s.store("\#{name}\#{i}", i.to_s, expires: false)
|
|
2149
2182
|
end
|
|
2150
2183
|
s.close
|
|
2151
2184
|
end
|
|
@@ -2172,7 +2205,7 @@ SPECS['concurrent_create'] = %{def create_thread(name)
|
|
|
2172
2205
|
Thread.new do
|
|
2173
2206
|
s = new_store
|
|
2174
2207
|
1000.times do |i|
|
|
2175
|
-
s[i.to_s].should == name if s.create(i.to_s, name, :
|
|
2208
|
+
s[i.to_s].should == name if s.create(i.to_s, name, expires: false)
|
|
2176
2209
|
Thread.pass if rand(100) >= 99
|
|
2177
2210
|
end
|
|
2178
2211
|
s.close
|
|
@@ -2194,9 +2227,9 @@ SPECS['increment'] = %{it 'initializes in #increment with 1' do
|
|
|
2194
2227
|
store.key?('inckey').should be_true
|
|
2195
2228
|
store.raw['inckey'].should == '1'
|
|
2196
2229
|
store.raw.load('inckey').should == '1'
|
|
2197
|
-
store.load('inckey', :
|
|
2230
|
+
store.load('inckey', raw: true).should == '1'
|
|
2198
2231
|
|
|
2199
|
-
store.delete('inckey', :
|
|
2232
|
+
store.delete('inckey', raw: true).should == '1'
|
|
2200
2233
|
store.key?('inckey').should be_false
|
|
2201
2234
|
end
|
|
2202
2235
|
|
|
@@ -2204,14 +2237,14 @@ it 'initializes in #increment with higher value' do
|
|
|
2204
2237
|
store.increment('inckey', 42).should == 42
|
|
2205
2238
|
store.key?('inckey').should be_true
|
|
2206
2239
|
store.raw['inckey'].should == '42'
|
|
2207
|
-
store.delete('inckey', :
|
|
2240
|
+
store.delete('inckey', raw: true).should == '42'
|
|
2208
2241
|
end
|
|
2209
2242
|
|
|
2210
2243
|
it 'initializes in #increment with 0' do
|
|
2211
2244
|
store.increment('inckey', 0).should == 0
|
|
2212
2245
|
store.key?('inckey').should be_true
|
|
2213
2246
|
store.raw['inckey'].should == '0'
|
|
2214
|
-
store.delete('inckey', :
|
|
2247
|
+
store.delete('inckey', raw: true).should == '0'
|
|
2215
2248
|
end
|
|
2216
2249
|
|
|
2217
2250
|
it 'initializes in #decrement with 0' do
|
|
@@ -2253,7 +2286,7 @@ it 'supports decrementing existing value' do
|
|
|
2253
2286
|
end
|
|
2254
2287
|
|
|
2255
2288
|
it 'interprets raw value as integer' do
|
|
2256
|
-
store.store('inckey', '42', :
|
|
2289
|
+
store.store('inckey', '42', raw: true)
|
|
2257
2290
|
store.increment('inckey').should == 43
|
|
2258
2291
|
store.raw['inckey'].should == '43'
|
|
2259
2292
|
end
|
|
@@ -2318,15 +2351,15 @@ SPECS['not_create'] = %{it 'does not support #create' do
|
|
|
2318
2351
|
end}
|
|
2319
2352
|
|
|
2320
2353
|
SPECS['create_expires'] = %{it 'creates the given key and expires it' do
|
|
2321
|
-
store.create('key','value', :
|
|
2354
|
+
store.create('key','value', expires: 1).should be_true
|
|
2322
2355
|
store['key'].should == 'value'
|
|
2323
2356
|
sleep 2
|
|
2324
2357
|
store.key?('key').should be_false
|
|
2325
2358
|
end
|
|
2326
2359
|
|
|
2327
2360
|
it 'does not change expires if the key exists' do
|
|
2328
|
-
store.store('key', 'value', :
|
|
2329
|
-
store.create('key','another value', :
|
|
2361
|
+
store.store('key', 'value', expires: false).should == 'value'
|
|
2362
|
+
store.create('key','another value', expires: 1).should be_false
|
|
2330
2363
|
store['key'].should == 'value'
|
|
2331
2364
|
sleep 2
|
|
2332
2365
|
store['key'].should == 'value'
|
|
@@ -2383,11 +2416,11 @@ end}
|
|
|
2383
2416
|
|
|
2384
2417
|
SPECS['transform_value'] = %{it 'allows to bypass transformer with :raw' do
|
|
2385
2418
|
store['key'] = 'value'
|
|
2386
|
-
load_value(store.load('key', :
|
|
2419
|
+
load_value(store.load('key', raw: true)).should == 'value'
|
|
2387
2420
|
|
|
2388
|
-
store.store('key', 'value', :
|
|
2389
|
-
store.load('key', :
|
|
2390
|
-
store.delete('key', :
|
|
2421
|
+
store.store('key', 'value', raw: true)
|
|
2422
|
+
store.load('key', raw: true).should == 'value'
|
|
2423
|
+
store.delete('key', raw: true).should == 'value'
|
|
2391
2424
|
end
|
|
2392
2425
|
|
|
2393
2426
|
it 'allows to bypass transformer with raw syntactic sugar' do
|
|
@@ -2404,12 +2437,12 @@ it 'allows to bypass transformer with raw syntactic sugar' do
|
|
|
2404
2437
|
end
|
|
2405
2438
|
|
|
2406
2439
|
it 'returns unmarshalled value' do
|
|
2407
|
-
store.store('key', 'unmarshalled value', :
|
|
2408
|
-
store.load('key', :
|
|
2440
|
+
store.store('key', 'unmarshalled value', raw: true)
|
|
2441
|
+
store.load('key', raw: true).should == 'unmarshalled value'
|
|
2409
2442
|
end
|
|
2410
2443
|
|
|
2411
2444
|
it 'might raise exception on invalid value' do
|
|
2412
|
-
store.store('key', 'unmarshalled value', :
|
|
2445
|
+
store.store('key', 'unmarshalled value', raw: true)
|
|
2413
2446
|
|
|
2414
2447
|
begin
|
|
2415
2448
|
store['key'].should == load_value('unmarshalled value')
|
|
@@ -2426,30 +2459,30 @@ end}
|
|
|
2426
2459
|
|
|
2427
2460
|
SPECS['transform_value_expires'] = %{it 'allows to bypass transformer with :raw' do
|
|
2428
2461
|
store['key'] = 'value'
|
|
2429
|
-
load_value(store.load('key', :
|
|
2462
|
+
load_value(store.load('key', raw: true)).should == 'value'
|
|
2430
2463
|
store['key'] = [1,2,3]
|
|
2431
|
-
load_value(store.load('key', :
|
|
2464
|
+
load_value(store.load('key', raw: true)).should == [[1,2,3]]
|
|
2432
2465
|
store['key'] = nil
|
|
2433
|
-
load_value(store.load('key', :
|
|
2466
|
+
load_value(store.load('key', raw: true)).should == [nil]
|
|
2434
2467
|
store['key'] = false
|
|
2435
|
-
load_value(store.load('key', :
|
|
2468
|
+
load_value(store.load('key', raw: true)).should be_false
|
|
2436
2469
|
|
|
2437
|
-
store.store('key', 'value', :
|
|
2438
|
-
load_value(store.load('key', :
|
|
2439
|
-
load_value(store.load('key', :
|
|
2470
|
+
store.store('key', 'value', expires: 10)
|
|
2471
|
+
load_value(store.load('key', raw: true)).first.should == 'value'
|
|
2472
|
+
load_value(store.load('key', raw: true)).last.should respond_to(:to_int)
|
|
2440
2473
|
|
|
2441
|
-
store.store('key', 'value', :
|
|
2442
|
-
store.load('key', :
|
|
2443
|
-
store.delete('key', :
|
|
2474
|
+
store.store('key', 'value', raw: true)
|
|
2475
|
+
store.load('key', raw: true).should == 'value'
|
|
2476
|
+
store.delete('key', raw: true).should == 'value'
|
|
2444
2477
|
end
|
|
2445
2478
|
|
|
2446
2479
|
it 'returns unmarshalled value' do
|
|
2447
|
-
store.store('key', 'unmarshalled value', :
|
|
2448
|
-
store.load('key', :
|
|
2480
|
+
store.store('key', 'unmarshalled value', raw: true)
|
|
2481
|
+
store.load('key', raw: true).should == 'unmarshalled value'
|
|
2449
2482
|
end
|
|
2450
2483
|
|
|
2451
2484
|
it 'might raise exception on invalid value' do
|
|
2452
|
-
store.store('key', 'unmarshalled value', :
|
|
2485
|
+
store.store('key', 'unmarshalled value', raw: true)
|
|
2453
2486
|
|
|
2454
2487
|
begin
|
|
2455
2488
|
store['key'].should == load_value('unmarshalled value')
|
|
@@ -2509,7 +2542,7 @@ TESTS.each do |name, options|
|
|
|
2509
2542
|
opts = options.delete(:options)
|
|
2510
2543
|
opts = ', ' << opts if opts
|
|
2511
2544
|
|
|
2512
|
-
build ||= "Moneta.new(#{store.inspect}#{opts}, :
|
|
2545
|
+
build ||= "Moneta.new(#{store.inspect}#{opts}, logger: {file: File.join(make_tempdir, '#{name}.log')})"
|
|
2513
2546
|
|
|
2514
2547
|
code = %{#{header}require 'helper'
|
|
2515
2548
|
|