moneta 1.2.0 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +418 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +27 -9
- data/CHANGES +28 -0
- data/CONTRIBUTORS +4 -2
- data/Gemfile +12 -8
- data/README.md +20 -18
- data/feature_matrix.yaml +2 -11
- data/lib/moneta.rb +9 -9
- data/lib/moneta/adapters/client.rb +56 -19
- data/lib/moneta/adapters/couch.rb +5 -0
- data/lib/moneta/adapters/mongo.rb +264 -7
- data/lib/moneta/adapters/redis.rb +5 -1
- data/lib/moneta/adapters/sequel.rb +45 -464
- data/lib/moneta/adapters/sequel/mysql.rb +66 -0
- data/lib/moneta/adapters/sequel/postgres.rb +80 -0
- data/lib/moneta/adapters/sequel/postgres_hstore.rb +240 -0
- data/lib/moneta/adapters/sequel/sqlite.rb +57 -0
- data/lib/moneta/adapters/sqlite.rb +7 -7
- data/lib/moneta/builder.rb +2 -2
- data/lib/moneta/create_support.rb +21 -0
- data/lib/moneta/dbm_adapter.rb +31 -0
- data/lib/moneta/{mixins.rb → defaults.rb} +1 -302
- data/lib/moneta/each_key_support.rb +27 -0
- data/lib/moneta/expires_support.rb +60 -0
- data/lib/moneta/hash_adapter.rb +68 -0
- data/lib/moneta/increment_support.rb +16 -0
- data/lib/moneta/lock.rb +6 -1
- data/lib/moneta/nil_values.rb +35 -0
- data/lib/moneta/option_support.rb +51 -0
- data/lib/moneta/pool.rb +38 -6
- data/lib/moneta/proxy.rb +1 -1
- data/lib/moneta/server.rb +215 -61
- data/lib/moneta/shared.rb +13 -7
- data/lib/moneta/transformer.rb +50 -8
- data/lib/moneta/transformer/config.rb +59 -40
- data/lib/moneta/transformer/helper.rb +2 -2
- data/lib/moneta/transformer/helper/bson.rb +5 -15
- data/lib/moneta/version.rb +1 -1
- data/lib/rack/cache/moneta.rb +14 -15
- data/moneta.gemspec +14 -8
- data/script/benchmarks +7 -3
- data/script/contributors +11 -6
- data/script/start-couchdb +27 -0
- data/script/start-hbase +2 -2
- data/script/start-services +3 -3
- data/spec/active_support/cache_moneta_store_spec.rb +37 -39
- data/spec/features/concurrent_increment.rb +2 -3
- data/spec/features/create_expires.rb +15 -15
- data/spec/features/default_expires.rb +11 -12
- data/spec/features/expires.rb +215 -210
- data/spec/features/store.rb +3 -3
- data/spec/helper.rb +33 -41
- data/spec/moneta/adapters/activerecord/adapter_activerecord_existing_connection_spec.rb +3 -1
- data/spec/moneta/adapters/activerecord/adapter_activerecord_spec.rb +15 -7
- data/spec/moneta/adapters/activerecord/standard_activerecord_spec.rb +6 -3
- data/spec/moneta/adapters/activerecord/standard_activerecord_with_expires_spec.rb +6 -3
- data/spec/moneta/adapters/activesupportcache/adapter_activesupportcache_spec.rb +3 -3
- data/spec/moneta/adapters/activesupportcache/adapter_activesupportcache_with_default_expires_spec.rb +2 -2
- data/spec/moneta/adapters/cassandra/standard_cassandra_spec.rb +1 -1
- data/spec/moneta/adapters/client/adapter_client_spec.rb +6 -6
- data/spec/moneta/adapters/client/client_helper.rb +24 -0
- data/spec/moneta/adapters/client/standard_client_tcp_spec.rb +8 -8
- data/spec/moneta/adapters/client/standard_client_unix_spec.rb +23 -7
- data/spec/moneta/adapters/couch/adapter_couch_spec.rb +1 -1
- data/spec/moneta/adapters/couch/standard_couch_spec.rb +2 -2
- data/spec/moneta/adapters/couch/standard_couch_with_expires_spec.rb +2 -2
- data/spec/moneta/adapters/datamapper/adapter_datamapper_spec.rb +25 -8
- data/spec/moneta/adapters/datamapper/standard_datamapper_spec.rb +2 -2
- data/spec/moneta/adapters/datamapper/standard_datamapper_with_expires_spec.rb +2 -2
- data/spec/moneta/adapters/datamapper/standard_datamapper_with_repository_spec.rb +2 -2
- data/spec/moneta/adapters/daybreak/standard_daybreak_spec.rb +1 -1
- data/spec/moneta/adapters/daybreak/standard_daybreak_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/dbm/standard_dbm_spec.rb +1 -1
- data/spec/moneta/adapters/dbm/standard_dbm_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/file/standard_file_spec.rb +2 -2
- data/spec/moneta/adapters/file/standard_file_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/gdbm/standard_gdbm_spec.rb +1 -1
- data/spec/moneta/adapters/gdbm/standard_gdbm_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/kyotocabinet/adapter_kyotocabinet_spec.rb +1 -1
- data/spec/moneta/adapters/kyotocabinet/standard_kyotocabinet_spec.rb +2 -2
- data/spec/moneta/adapters/kyotocabinet/standard_kyotocabinet_with_expires_spec.rb +2 -2
- data/spec/moneta/adapters/leveldb/standard_leveldb_spec.rb +1 -1
- data/spec/moneta/adapters/leveldb/standard_leveldb_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/lmdb/standard_lmdb_spec.rb +1 -1
- data/spec/moneta/adapters/lmdb/standard_lmdb_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/lruhash/standard_lruhash_spec.rb +1 -1
- data/spec/moneta/adapters/lruhash/standard_lruhash_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/memcached/dalli/adapter_memcached_dalli_spec.rb +13 -3
- data/spec/moneta/adapters/memcached/native/adapter_memcached_native_spec.rb +13 -3
- data/spec/moneta/adapters/memory/standard_memory_spec.rb +1 -1
- data/spec/moneta/adapters/memory/standard_memory_with_compress_spec.rb +1 -1
- data/spec/moneta/adapters/memory/standard_memory_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/memory/standard_memory_with_json_key_serializer_spec.rb +1 -1
- data/spec/moneta/adapters/memory/standard_memory_with_json_serializer_spec.rb +1 -1
- data/spec/moneta/adapters/memory/standard_memory_with_json_value_serializer_spec.rb +2 -2
- data/spec/moneta/adapters/memory/standard_memory_with_prefix_spec.rb +39 -2
- data/spec/moneta/adapters/memory/standard_memory_with_snappy_compress_spec.rb +2 -2
- data/spec/moneta/adapters/mongo/adapter_mongo_spec.rb +32 -2
- data/spec/moneta/adapters/mongo/adapter_mongo_with_default_expires_spec.rb +6 -4
- data/spec/moneta/adapters/mongo/standard_mongo_spec.rb +2 -2
- data/spec/moneta/adapters/pstore/standard_pstore_spec.rb +1 -1
- data/spec/moneta/adapters/pstore/standard_pstore_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/redis/adapter_redis_spec.rb +13 -3
- data/spec/moneta/adapters/redis/standard_redis_spec.rb +9 -2
- data/spec/moneta/adapters/sdbm/standard_sdbm_spec.rb +1 -1
- data/spec/moneta/adapters/sdbm/standard_sdbm_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/sequel/adapter_sequel_spec.rb +11 -38
- data/spec/moneta/adapters/sequel/helper.rb +42 -0
- data/spec/moneta/adapters/sequel/standard_sequel_spec.rb +6 -12
- data/spec/moneta/adapters/sequel/standard_sequel_with_expires_spec.rb +9 -10
- data/spec/moneta/adapters/sqlite/adapter_sqlite_spec.rb +1 -1
- data/spec/moneta/adapters/sqlite/standard_sqlite_spec.rb +2 -2
- data/spec/moneta/adapters/sqlite/standard_sqlite_with_expires_spec.rb +2 -2
- data/spec/moneta/adapters/tdb/standard_tdb_spec.rb +1 -1
- data/spec/moneta/adapters/tdb/standard_tdb_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/tokyocabinet/standard_tokyocabinet_spec.rb +1 -1
- data/spec/moneta/adapters/tokyocabinet/standard_tokyocabinet_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/yaml/standard_yaml_spec.rb +1 -1
- data/spec/moneta/adapters/yaml/standard_yaml_with_expires_spec.rb +1 -1
- data/spec/moneta/builder_spec.rb +22 -0
- data/spec/moneta/proxies/expires/expires_file_spec.rb +1 -1
- data/spec/moneta/proxies/pool/pool_spec.rb +31 -3
- data/spec/moneta/proxies/shared/shared_tcp_spec.rb +14 -4
- data/spec/moneta/proxies/shared/shared_unix_spec.rb +14 -4
- data/spec/moneta/proxies/transformer/transformer_bencode_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_bert_spec.rb +3 -3
- data/spec/moneta/proxies/transformer/transformer_bson_spec.rb +2 -2
- data/spec/moneta/proxies/transformer/transformer_json_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_key_marshal_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_key_yaml_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_marshal_base64_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_marshal_escape_spec.rb +8 -4
- data/spec/moneta/proxies/transformer/transformer_marshal_hex_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_marshal_hmac_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_marshal_prefix_base64_spec.rb +33 -0
- data/spec/moneta/proxies/transformer/transformer_marshal_prefix_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_marshal_qp_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_marshal_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_marshal_urlsafe_base64_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_marshal_uuencode_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_msgpack_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_ox_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_php_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_tnet_spec.rb +1 -1
- data/spec/moneta/proxies/transformer/transformer_yaml_spec.rb +2 -2
- data/spec/moneta/proxies/weak_each_key/weak_each_key_spec.rb +0 -2
- data/spec/restserver.rb +15 -0
- metadata +47 -66
- data/.travis.yml +0 -140
- data/lib/moneta/adapters/mongo/base.rb +0 -103
- data/lib/moneta/adapters/mongo/moped.rb +0 -163
- data/lib/moneta/adapters/mongo/official.rb +0 -156
- data/script/reconfigure-couchdb +0 -13
- data/spec/moneta/adapters/memcached/dalli/adapter_memcached_dalli_with_default_expires_spec.rb +0 -15
- data/spec/moneta/adapters/memcached/native/adapter_memcached_native_with_default_expires_spec.rb +0 -15
- data/spec/moneta/adapters/mongo/adapter_mongo_moped_spec.rb +0 -25
- data/spec/moneta/adapters/mongo/adapter_mongo_moped_with_default_expires_spec.rb +0 -12
- data/spec/moneta/adapters/mongo/adapter_mongo_official_spec.rb +0 -25
- data/spec/moneta/adapters/mongo/adapter_mongo_official_with_default_expires_spec.rb +0 -12
- data/spec/moneta/adapters/mongo/standard_mongo_moped_spec.rb +0 -7
- data/spec/moneta/adapters/mongo/standard_mongo_official_spec.rb +0 -7
- data/spec/moneta/adapters/redis/adapter_redis_with_default_expires_spec.rb +0 -10
- data/spec/moneta/proxies/proxy/proxy_redis_spec.rb +0 -13
- data/spec/quality_spec.rb +0 -51
@@ -1,11 +1,13 @@
|
|
1
1
|
describe 'adapter_mongo_with_default_expires', isolate: true, adapter: :Mongo do
|
2
2
|
let(:t_res) { 0.125 }
|
3
|
-
let(:min_ttl) { t_res }
|
3
|
+
let(:min_ttl) { t_res * 4 }
|
4
4
|
|
5
5
|
moneta_build do
|
6
|
-
Moneta::Adapters::Mongo.new(
|
7
|
-
|
8
|
-
|
6
|
+
Moneta::Adapters::Mongo.new(
|
7
|
+
database: File.basename(__FILE__, '.rb'),
|
8
|
+
collection: 'adapter_mongo_with_default_expires',
|
9
|
+
expires: min_ttl
|
10
|
+
)
|
9
11
|
end
|
10
12
|
|
11
13
|
moneta_specs ADAPTER_SPECS.with_each_key.with_expires.with_default_expires.simplevalues_only
|
@@ -2,6 +2,6 @@ describe 'standard_mongo', adapter: :Mongo do
|
|
2
2
|
let(:t_res) { 0.125 }
|
3
3
|
let(:min_ttl) { t_res }
|
4
4
|
|
5
|
-
moneta_store :Mongo, {
|
6
|
-
moneta_specs STANDARD_SPECS.with_native_expires
|
5
|
+
moneta_store :Mongo, {database: File.basename(__FILE__, '.rb'), collection: 'standard_mongo'}
|
6
|
+
moneta_specs STANDARD_SPECS.with_native_expires.with_each_key
|
7
7
|
end
|
@@ -2,9 +2,19 @@ describe 'adapter_redis', adapter: :Redis do
|
|
2
2
|
let(:t_res) { 0.125 }
|
3
3
|
let(:min_ttl) { t_res }
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
describe 'without default expiry' do
|
6
|
+
moneta_build do
|
7
|
+
Moneta::Adapters::Redis.new(host: redis_host, port: redis_port, db: 6)
|
8
|
+
end
|
9
|
+
|
10
|
+
moneta_specs ADAPTER_SPECS.with_each_key.with_native_expires
|
7
11
|
end
|
8
12
|
|
9
|
-
|
13
|
+
describe 'with default expiry' do
|
14
|
+
moneta_build do
|
15
|
+
Moneta::Adapters::Redis.new(host: redis_host, port: redis_port, db: 6, expires: min_ttl)
|
16
|
+
end
|
17
|
+
|
18
|
+
moneta_specs NATIVE_EXPIRY_SPECS.with_default_expires
|
19
|
+
end
|
10
20
|
end
|
@@ -2,6 +2,13 @@ describe 'standard_redis', adapter: :Redis do
|
|
2
2
|
let(:t_res) { 0.125 }
|
3
3
|
let(:min_ttl) { t_res }
|
4
4
|
|
5
|
-
moneta_store :Redis
|
6
|
-
|
5
|
+
moneta_store :Redis do
|
6
|
+
{
|
7
|
+
db: 4,
|
8
|
+
host: redis_host,
|
9
|
+
port: redis_port
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
moneta_specs STANDARD_SPECS.with_native_expires.with_each_key
|
7
14
|
end
|
@@ -3,5 +3,5 @@ describe 'standard_sdbm', unsupported: defined?(JRUBY_VERSION), adapter: :SDBM d
|
|
3
3
|
{file: File.join(tempdir, "simple_sdbm")}
|
4
4
|
end
|
5
5
|
|
6
|
-
moneta_specs STANDARD_SPECS.without_multiprocess.without_large
|
6
|
+
moneta_specs STANDARD_SPECS.without_multiprocess.without_large.with_each_key
|
7
7
|
end
|
@@ -7,5 +7,5 @@ describe 'standard_sdbm_with_expires', unsupported: defined?(JRUBY_VERSION), ada
|
|
7
7
|
{file: File.join(tempdir, "simple_sdbm_with_expires"), expires: true}
|
8
8
|
end
|
9
9
|
|
10
|
-
moneta_specs STANDARD_SPECS.without_multiprocess.with_expires.without_large
|
10
|
+
moneta_specs STANDARD_SPECS.without_multiprocess.with_expires.without_large.with_each_key
|
11
11
|
end
|
@@ -1,43 +1,29 @@
|
|
1
1
|
require_relative './helper.rb'
|
2
2
|
|
3
3
|
describe ':Sequel adapter', adapter: :Sequel do
|
4
|
+
include_context :sequel
|
5
|
+
|
4
6
|
specs = ADAPTER_SPECS.with_each_key.with_values(:nil)
|
5
7
|
|
6
|
-
context 'with MySQL backend' do
|
8
|
+
context 'with MySQL backend', mysql: true do
|
7
9
|
moneta_build do
|
8
|
-
Moneta::Adapters::Sequel.new(opts.merge(
|
9
|
-
db: if defined?(JRUBY_VERSION)
|
10
|
-
"jdbc:mysql://localhost/#{mysql_database1}?user=#{mysql_username}"
|
11
|
-
else
|
12
|
-
"mysql2://#{mysql_username}:@localhost/#{mysql_database1}"
|
13
|
-
end
|
14
|
-
))
|
10
|
+
Moneta::Adapters::Sequel.new(opts.merge(db: mysql_uri))
|
15
11
|
end
|
16
12
|
|
17
13
|
include_examples :adapter_sequel, specs
|
18
14
|
end
|
19
15
|
|
20
|
-
context "with SQLite backend" do
|
16
|
+
context "with SQLite backend", sqlite: true do
|
21
17
|
moneta_build do
|
22
|
-
Moneta::Adapters::Sequel.new(opts.merge(
|
23
|
-
db: "#{defined?(JRUBY_VERSION) && 'jdbc:'}sqlite://" + File.join(tempdir, 'adapter_sequel.db')))
|
18
|
+
Moneta::Adapters::Sequel.new(opts.merge(db: sqlite_uri('adapter_sequel.db')))
|
24
19
|
end
|
25
20
|
|
26
21
|
include_examples :adapter_sequel, specs.without_concurrent
|
27
22
|
end
|
28
23
|
|
29
|
-
context "with Postgres backend" do
|
24
|
+
context "with Postgres backend", postgres: true do
|
30
25
|
moneta_build do
|
31
|
-
Moneta::Adapters::Sequel.new(opts.merge(
|
32
|
-
if defined?(JRUBY_VERSION)
|
33
|
-
{db: "jdbc:postgresql://localhost/#{postgres_database1}?user=#{postgres_username}"}
|
34
|
-
else
|
35
|
-
{
|
36
|
-
db: "postgres://localhost/#{postgres_database1}",
|
37
|
-
user: postgres_username
|
38
|
-
}
|
39
|
-
end
|
40
|
-
))
|
26
|
+
Moneta::Adapters::Sequel.new(opts.merge(postgres_options))
|
41
27
|
end
|
42
28
|
|
43
29
|
include_examples :adapter_sequel, specs
|
@@ -45,28 +31,15 @@ describe ':Sequel adapter', adapter: :Sequel do
|
|
45
31
|
|
46
32
|
context "with H2 backend", unsupported: !defined?(JRUBY_VERSION) do
|
47
33
|
moneta_build do
|
48
|
-
Moneta::Adapters::Sequel.new(opts.merge(
|
49
|
-
db: "jdbc:h2:" + tempdir))
|
34
|
+
Moneta::Adapters::Sequel.new(opts.merge(db: h2_uri))
|
50
35
|
end
|
51
36
|
|
52
37
|
include_examples :adapter_sequel, specs, optimize: false
|
53
38
|
end
|
54
39
|
|
55
|
-
context "with Postgres HStore backend" do
|
40
|
+
context "with Postgres HStore backend", postgres: true do
|
56
41
|
moneta_build do
|
57
|
-
Moneta::Adapters::Sequel.new(
|
58
|
-
if defined?(JRUBY_VERSION)
|
59
|
-
{db: "jdbc:postgresql://localhost/#{postgres_database1}?user=#{postgres_username}"}
|
60
|
-
else
|
61
|
-
{
|
62
|
-
db: "postgres://localhost/#{postgres_database1}",
|
63
|
-
user: postgres_username
|
64
|
-
}
|
65
|
-
end.merge(
|
66
|
-
table: 'hstore_table1',
|
67
|
-
hstore: 'row'
|
68
|
-
)
|
69
|
-
)
|
42
|
+
Moneta::Adapters::Sequel.new(postgres_hstore_options)
|
70
43
|
end
|
71
44
|
|
72
45
|
# Concurrency is too slow, and binary values cannot be stored in an hstore
|
@@ -1,3 +1,45 @@
|
|
1
|
+
RSpec.shared_context :sequel do
|
2
|
+
def mysql_uri database=nil
|
3
|
+
database ||= mysql_database1
|
4
|
+
if defined?(JRUBY_VERSION)
|
5
|
+
uri = "jdbc:mysql://#{mysql_host}:#{mysql_port}/#{database}?user=#{mysql_username}&useSSL=false"
|
6
|
+
uri += "&password=#{mysql_password}" if mysql_password
|
7
|
+
uri
|
8
|
+
else
|
9
|
+
"mysql2://#{mysql_username}:#{mysql_password}@#{mysql_host}:#{mysql_port}/#{database}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def sqlite_uri file_name
|
14
|
+
"#{defined?(JRUBY_VERSION) && 'jdbc:'}sqlite://" + File.join(tempdir, file_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def postgres_options database=nil
|
18
|
+
database ||= postgres_database1
|
19
|
+
if defined?(JRUBY_VERSION)
|
20
|
+
uri = "jdbc:postgresql://localhost/#{database}?user=#{postgres_username}"
|
21
|
+
uri += "&password=#{postgres_password}" if postgres_password
|
22
|
+
{db: uri}
|
23
|
+
else
|
24
|
+
{
|
25
|
+
db: "postgres://localhost/#{database}",
|
26
|
+
user: postgres_username,
|
27
|
+
password: postgres_password
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def postgres_hstore_options database=nil
|
33
|
+
postgres_options(database).merge \
|
34
|
+
table: 'hstore_table1',
|
35
|
+
hstore: 'row'
|
36
|
+
end
|
37
|
+
|
38
|
+
def h2_uri
|
39
|
+
"jdbc:h2:" + tempdir
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
1
43
|
RSpec.shared_examples :adapter_sequel do |specs, optimize: true|
|
2
44
|
shared_examples :each_key_server do
|
3
45
|
context "with each_key server" do
|
@@ -1,14 +1,8 @@
|
|
1
|
-
|
2
|
-
moneta_store :Sequel do
|
3
|
-
{
|
4
|
-
db: if defined?(JRUBY_VERSION)
|
5
|
-
"jdbc:mysql://localhost/#{mysql_database1}?user=#{mysql_username}"
|
6
|
-
else
|
7
|
-
"mysql2://#{mysql_username}:@localhost/#{mysql_database1}"
|
8
|
-
end,
|
9
|
-
table: "simple_sequel"
|
10
|
-
}
|
11
|
-
end
|
1
|
+
require_relative './helper.rb'
|
12
2
|
|
13
|
-
|
3
|
+
describe 'standard_sequel', adapter: :Sequel, postgres: true do
|
4
|
+
include_context :sequel
|
5
|
+
|
6
|
+
moneta_store(:Sequel) { postgres_options.merge(table: "standard_sequel") }
|
7
|
+
moneta_specs STANDARD_SPECS.with_each_key
|
14
8
|
end
|
@@ -1,19 +1,18 @@
|
|
1
|
-
|
1
|
+
require_relative './helper.rb'
|
2
|
+
|
3
|
+
describe 'standard_sequel_with_expires', adapter: :Sequel, postgres: true do
|
4
|
+
include_context :sequel
|
5
|
+
|
2
6
|
let(:t_res) { 0.125 }
|
3
7
|
let(:min_ttl) { t_res }
|
4
8
|
use_timecop
|
5
9
|
|
6
10
|
moneta_store :Sequel do
|
7
|
-
|
8
|
-
|
9
|
-
"jdbc:mysql://localhost/#{mysql_database1}?user=#{mysql_username}"
|
10
|
-
else
|
11
|
-
"mysql2://#{mysql_username}:@localhost/#{mysql_database1}"
|
12
|
-
end,
|
13
|
-
table: "simple_sequel_with_expires",
|
11
|
+
postgres_options.merge(
|
12
|
+
table: "standard_sequel_with_expires",
|
14
13
|
expires: true
|
15
|
-
|
14
|
+
)
|
16
15
|
end
|
17
16
|
|
18
|
-
moneta_specs STANDARD_SPECS.with_expires
|
17
|
+
moneta_specs STANDARD_SPECS.with_expires.with_each_key
|
19
18
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe 'adapter_sqlite', unsupported: defined?(JRUBY_VERSION), adapter: :Sqlite do
|
1
|
+
describe 'adapter_sqlite', unsupported: defined?(JRUBY_VERSION), adapter: :Sqlite, sqlite: true do
|
2
2
|
moneta_build do
|
3
3
|
Moneta::Adapters::Sqlite.new(file: File.join(tempdir, "adapter_sqlite"))
|
4
4
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
describe 'standard_sqlite', unsupported: defined?(JRUBY_VERSION), adapter: :Sqlite do
|
1
|
+
describe 'standard_sqlite', unsupported: defined?(JRUBY_VERSION), adapter: :Sqlite, sqlite: true do
|
2
2
|
moneta_store :Sqlite do
|
3
3
|
{file: File.join(tempdir, "standard_sqlite")}
|
4
4
|
end
|
5
5
|
|
6
|
-
moneta_specs STANDARD_SPECS.without_concurrent
|
6
|
+
moneta_specs STANDARD_SPECS.without_concurrent.with_each_key
|
7
7
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe 'standard_sqlite_with_expires', unsupported: defined?(JRUBY_VERSION), adapter: :Sqlite do
|
1
|
+
describe 'standard_sqlite_with_expires', unsupported: defined?(JRUBY_VERSION), adapter: :Sqlite, sqlite: true do
|
2
2
|
let(:t_res) { 0.125 }
|
3
3
|
let(:min_ttl) { 1 }
|
4
4
|
use_timecop
|
@@ -11,5 +11,5 @@ describe 'standard_sqlite_with_expires', unsupported: defined?(JRUBY_VERSION), a
|
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
14
|
-
moneta_specs STANDARD_SPECS.with_expires.without_concurrent
|
14
|
+
moneta_specs STANDARD_SPECS.with_expires.without_concurrent.with_each_key
|
15
15
|
end
|
@@ -7,5 +7,5 @@ describe 'standard_tdb_with_expires', unsupported: defined?(JRUBY_VERSION), adap
|
|
7
7
|
{file: File.join(tempdir, "simple_tdb_with_expires"), expires: true}
|
8
8
|
end
|
9
9
|
|
10
|
-
moneta_specs STANDARD_SPECS.without_multiprocess.with_expires
|
10
|
+
moneta_specs STANDARD_SPECS.without_multiprocess.with_expires.with_each_key
|
11
11
|
end
|
@@ -7,5 +7,5 @@ describe 'standard_tokyocabinet_with_expires', unsupported: defined?(JRUBY_VERSI
|
|
7
7
|
{file: File.join(tempdir, "simple_tokyocabinet_with_expires"), expires: true}
|
8
8
|
end
|
9
9
|
|
10
|
-
moneta_specs STANDARD_SPECS.without_multiprocess.with_expires
|
10
|
+
moneta_specs STANDARD_SPECS.without_multiprocess.with_expires.with_each_key
|
11
11
|
end
|
@@ -9,5 +9,5 @@ describe 'standard_yaml_with_expires', adapter: :YAML do
|
|
9
9
|
|
10
10
|
moneta_loader{ |value| value }
|
11
11
|
|
12
|
-
moneta_specs STANDARD_SPECS.without_marshallable_value.with_expires.without_concurrent
|
12
|
+
moneta_specs STANDARD_SPECS.without_marshallable_value.with_expires.without_concurrent.with_each_key
|
13
13
|
end
|
data/spec/moneta/builder_spec.rb
CHANGED
@@ -25,4 +25,26 @@ describe Moneta::Builder do
|
|
25
25
|
end.build
|
26
26
|
end.to raise_error /Please check/
|
27
27
|
end
|
28
|
+
|
29
|
+
it 'dups options before passing them to each middleware' do
|
30
|
+
my_adapter = Class.new do
|
31
|
+
def initialize(options)
|
32
|
+
throw "a is missing" unless options.delete(:a)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
my_middleware = Class.new do
|
37
|
+
def initialize(backend, options)
|
38
|
+
throw "a is missing" unless options.delete(:a)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
options = { a: 1 }
|
43
|
+
Moneta::Builder.new do
|
44
|
+
use my_middleware, options
|
45
|
+
adapter my_adapter, options
|
46
|
+
end.build
|
47
|
+
|
48
|
+
expect(options).to include(a: 1)
|
49
|
+
end
|
28
50
|
end
|
@@ -13,7 +13,7 @@ describe 'expires_file', proxy: :Expires do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
moneta_specs STANDARD_SPECS.with_expires.stringvalues_only
|
16
|
+
moneta_specs STANDARD_SPECS.with_expires.stringvalues_only.with_each_key
|
17
17
|
|
18
18
|
it 'deletes expired value in underlying file storage' do
|
19
19
|
store.store('foo', 'bar', expires: 2)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'timeout'
|
2
2
|
|
3
|
-
describe "pool", proxy: :Pool do
|
3
|
+
describe "pool", proxy: :Pool, broken: ::Gem::Version.new(RUBY_ENGINE_VERSION) < ::Gem::Version.new('2.4.0') do
|
4
4
|
describe "Moneta::Pool" do
|
5
5
|
# To test the pool, we create the store once and pass the same object around
|
6
6
|
# whenever a new store is requested.
|
@@ -153,7 +153,7 @@ describe "pool", proxy: :Pool do
|
|
153
153
|
describe "closing stores after TTL expiry" do
|
154
154
|
let(:num) { max || min + 10 }
|
155
155
|
|
156
|
-
it "closes
|
156
|
+
it "closes unneeded stores after ttl" do
|
157
157
|
stores.each do |store|
|
158
158
|
allow(store).to receive(:close)
|
159
159
|
end
|
@@ -169,6 +169,32 @@ describe "pool", proxy: :Pool do
|
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
+
shared_examples :ttl_with_nonzero_min do |ttl:, min:, max: nil|
|
173
|
+
describe "TTL check" do
|
174
|
+
let(:num) { max || min + 10 }
|
175
|
+
|
176
|
+
# This is testing that a very specific bug is fixed - see
|
177
|
+
# https://github.com/moneta-rb/moneta/issues/197. A better long-term
|
178
|
+
# solution would be to have more granular tests of the functions in the
|
179
|
+
# PoolManager
|
180
|
+
it "doesn't cause a busy-loop when there are available stores" do
|
181
|
+
# Check a store in and out - now the manager needs to decide whether to close
|
182
|
+
# stores after ttl seconds.
|
183
|
+
store = subject.check_out
|
184
|
+
subject.check_in(store)
|
185
|
+
sleep ttl
|
186
|
+
expect(subject.stats[:available]).to be > 0
|
187
|
+
|
188
|
+
# needs to be less than the TTL, but otherwise not important.
|
189
|
+
sleep_time = ttl / 2.0
|
190
|
+
sleep sleep_time
|
191
|
+
|
192
|
+
# during the sleep, the pool manager should have been idle.
|
193
|
+
expect(subject.stats[:idle_time]).to be >= sleep_time
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
172
198
|
shared_examples :timeout do |timeout, max:|
|
173
199
|
describe "raising an error after timeout" do
|
174
200
|
let(:num) { max }
|
@@ -233,6 +259,7 @@ describe "pool", proxy: :Pool do
|
|
233
259
|
include_examples :min, 10
|
234
260
|
include_examples :max, 20, timeout: 4
|
235
261
|
include_examples :ttl, 1, min: 10, max: 20
|
262
|
+
include_examples :ttl_with_nonzero_min, ttl: 1, min: 10, max: 20
|
236
263
|
include_examples :timeout, 4, max: 20
|
237
264
|
end
|
238
265
|
|
@@ -243,6 +270,7 @@ describe "pool", proxy: :Pool do
|
|
243
270
|
include_examples :min, 10
|
244
271
|
include_examples :max, 10, timeout: 4
|
245
272
|
include_examples :ttl, 2, min: 10, max: 10
|
273
|
+
include_examples :ttl_with_nonzero_min, ttl: 2, min: 10, max: 10
|
246
274
|
include_examples :timeout, 4, max: 10
|
247
275
|
end
|
248
276
|
|
@@ -292,7 +320,7 @@ describe "pool", proxy: :Pool do
|
|
292
320
|
end
|
293
321
|
|
294
322
|
it "raises a ShutdownError if the pool is stopped while waiting for a store" do
|
295
|
-
#
|
323
|
+
# Exhaust the pool
|
296
324
|
store = stores.first
|
297
325
|
allow(store).to receive(:close).once
|
298
326
|
expect(subject.check_out).to eq store
|