moneta 1.1.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +194 -0
- data/.travis.yml +65 -25
- data/CHANGES +36 -0
- data/CONTRIBUTORS +4 -2
- data/Gemfile +94 -65
- data/README.md +50 -25
- data/feature_matrix.yaml +3 -11
- data/lib/action_dispatch/middleware/session/moneta_store.rb +1 -0
- data/lib/active_support/cache/moneta_store.rb +5 -5
- data/lib/moneta.rb +20 -10
- data/lib/moneta/adapters/activerecord.rb +35 -19
- data/lib/moneta/adapters/activesupportcache.rb +3 -7
- data/lib/moneta/adapters/cassandra.rb +24 -16
- data/lib/moneta/adapters/client.rb +62 -21
- data/lib/moneta/adapters/couch.rb +225 -80
- data/lib/moneta/adapters/datamapper.rb +1 -0
- data/lib/moneta/adapters/file.rb +9 -6
- data/lib/moneta/adapters/hbase.rb +1 -1
- data/lib/moneta/adapters/kyotocabinet.rb +8 -7
- data/lib/moneta/adapters/leveldb.rb +1 -1
- data/lib/moneta/adapters/lmdb.rb +3 -4
- data/lib/moneta/adapters/lruhash.rb +29 -62
- data/lib/moneta/adapters/memcached.rb +1 -0
- data/lib/moneta/adapters/memcached/dalli.rb +1 -1
- data/lib/moneta/adapters/memcached/native.rb +10 -8
- data/lib/moneta/adapters/mongo.rb +256 -6
- data/lib/moneta/adapters/null.rb +1 -2
- data/lib/moneta/adapters/pstore.rb +3 -2
- data/lib/moneta/adapters/redis.rb +8 -4
- data/lib/moneta/adapters/restclient.rb +12 -3
- data/lib/moneta/adapters/riak.rb +2 -2
- data/lib/moneta/adapters/sequel.rb +137 -328
- 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 +25 -11
- data/lib/moneta/adapters/tokyotyrant.rb +1 -1
- data/lib/moneta/builder.rb +2 -3
- data/lib/moneta/create_support.rb +21 -0
- data/lib/moneta/dbm_adapter.rb +31 -0
- data/lib/moneta/{mixins.rb → defaults.rb} +3 -302
- data/lib/moneta/each_key_support.rb +27 -0
- data/lib/moneta/enumerable.rb +38 -0
- data/lib/moneta/expires.rb +12 -12
- data/lib/moneta/expires_support.rb +60 -0
- data/lib/moneta/fallback.rb +84 -0
- data/lib/moneta/hash_adapter.rb +68 -0
- data/lib/moneta/increment_support.rb +16 -0
- data/lib/moneta/lock.rb +7 -2
- data/lib/moneta/logger.rb +2 -2
- data/lib/moneta/nil_values.rb +35 -0
- data/lib/moneta/option_support.rb +51 -0
- data/lib/moneta/optionmerger.rb +0 -1
- data/lib/moneta/pool.rb +312 -30
- data/lib/moneta/proxy.rb +3 -3
- data/lib/moneta/server.rb +216 -65
- data/lib/moneta/shared.rb +13 -7
- data/lib/moneta/stack.rb +6 -6
- data/lib/moneta/synchronize.rb +3 -3
- data/lib/moneta/transformer.rb +68 -24
- data/lib/moneta/transformer/config.rb +63 -43
- data/lib/moneta/transformer/helper.rb +3 -3
- data/lib/moneta/transformer/helper/bson.rb +7 -14
- data/lib/moneta/utils.rb +3 -9
- data/lib/moneta/version.rb +1 -1
- data/lib/moneta/weak_each_key.rb +2 -4
- data/lib/rack/cache/moneta.rb +13 -11
- data/lib/rack/moneta_rest.rb +2 -2
- data/lib/rack/session/moneta.rb +3 -4
- data/moneta.gemspec +18 -4
- data/script/benchmarks +145 -46
- data/script/contributors +11 -6
- data/script/start-couchdb +27 -0
- data/script/start-hbase +3 -2
- data/script/start-services +3 -11
- data/spec/active_support/cache_moneta_store_spec.rb +30 -30
- data/spec/features/concurrent_create.rb +31 -10
- data/spec/features/concurrent_increment.rb +26 -19
- 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/increment.rb +41 -41
- data/spec/features/store.rb +3 -3
- data/spec/helper.rb +23 -82
- data/spec/moneta/adapters/activerecord/standard_activerecord_spec.rb +1 -1
- data/spec/moneta/adapters/activerecord/standard_activerecord_with_expires_spec.rb +1 -1
- data/spec/moneta/adapters/activesupportcache/adapter_activesupportcache_spec.rb +4 -1
- data/spec/moneta/adapters/activesupportcache/adapter_activesupportcache_with_default_expires_spec.rb +4 -1
- data/spec/moneta/adapters/activesupportcache/standard_activesupportcache_spec.rb +14 -0
- 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 +199 -2
- data/spec/moneta/adapters/couch/standard_couch_spec.rb +9 -3
- data/spec/moneta/adapters/couch/standard_couch_with_expires_spec.rb +8 -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/faraday_helper.rb +9 -0
- 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/adapter_lruhash_spec.rb +2 -2
- 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/adapter_memcached_spec.rb +1 -1
- data/spec/moneta/adapters/memcached/dalli/adapter_memcached_dalli_spec.rb +1 -1
- data/spec/moneta/adapters/memcached/dalli/adapter_memcached_dalli_with_default_expires_spec.rb +1 -1
- data/spec/moneta/adapters/memcached/dalli/standard_memcached_dalli_spec.rb +1 -1
- data/spec/moneta/adapters/memcached/native/adapter_memcached_native_spec.rb +1 -1
- data/spec/moneta/adapters/memcached/native/adapter_memcached_native_with_default_expires_spec.rb +1 -1
- data/spec/moneta/adapters/memcached/native/standard_memcached_native_spec.rb +1 -1
- data/spec/moneta/adapters/memcached/standard_memcached_spec.rb +1 -1
- data/spec/moneta/adapters/{memcached/helper.rb → memcached_helper.rb} +0 -0
- 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 +18 -2
- data/spec/moneta/adapters/mongo/adapter_mongo_with_default_expires_spec.rb +5 -3
- data/spec/moneta/adapters/mongo/standard_mongo_spec.rb +2 -2
- data/spec/moneta/adapters/null/null_adapter_spec.rb +1 -1
- 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/standard_redis_spec.rb +1 -1
- data/spec/moneta/adapters/restclient/adapter_restclient_spec.rb +7 -5
- data/spec/moneta/adapters/restclient/helper.rb +12 -0
- data/spec/moneta/adapters/restclient/standard_restclient_spec.rb +9 -6
- data/spec/moneta/adapters/riak/standard_riak_with_expires_spec.rb +4 -0
- 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 +31 -79
- data/spec/moneta/adapters/sequel/helper.rb +75 -0
- data/spec/moneta/adapters/sequel/standard_sequel_spec.rb +5 -11
- data/spec/moneta/adapters/sequel/standard_sequel_with_expires_spec.rb +8 -9
- data/spec/moneta/adapters/sqlite/standard_sqlite_spec.rb +1 -1
- data/spec/moneta/adapters/sqlite/standard_sqlite_with_expires_spec.rb +1 -1
- 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/tokyotyrant/adapter_tokyotyrant_spec.rb +6 -2
- data/spec/moneta/adapters/tokyotyrant/helper.rb +12 -0
- data/spec/moneta/adapters/tokyotyrant/standard_tokyotyrant_spec.rb +5 -2
- data/spec/moneta/adapters/tokyotyrant/standard_tokyotyrant_with_expires_spec.rb +5 -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/enumerable/enumerable_spec.rb +26 -0
- data/spec/moneta/proxies/expires/expires_file_spec.rb +1 -1
- data/spec/moneta/proxies/fallback/fallback_spec.rb +42 -0
- data/spec/moneta/proxies/pool/pool_spec.rb +319 -6
- 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 +55 -0
- data/spec/support/mongo_helper.rb +12 -0
- metadata +140 -32
- data/lib/moneta/adapters/mongo/base.rb +0 -103
- data/lib/moneta/adapters/mongo/moped.rb +0 -164
- data/lib/moneta/adapters/mongo/official.rb +0 -157
- data/script/install-kyotocabinet +0 -17
- 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/quality_spec.rb +0 -51
@@ -1,12 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
require_relative './client_helper.rb'
|
2
|
+
|
3
|
+
describe "standard_client_unix", adapter: :Client do
|
4
|
+
include_context :start_server,
|
5
|
+
backend: ->{ Moneta::Adapters::Memory.new },
|
6
|
+
socket: ->{ File.join(tempdir, 'standard_client_unix') }
|
6
7
|
|
7
8
|
moneta_store :Client do
|
8
|
-
{socket: File.join(tempdir, 'standard_client_unix')}
|
9
|
+
{ socket: File.join(tempdir, 'standard_client_unix') }
|
9
10
|
end
|
10
11
|
|
11
|
-
moneta_specs STANDARD_SPECS
|
12
|
+
moneta_specs STANDARD_SPECS.with_each_key
|
13
|
+
|
14
|
+
it 'supports multiple clients' do
|
15
|
+
store['shared_key'] = 'shared_val'
|
16
|
+
threads = (1..32).map do |i|
|
17
|
+
Thread.new do
|
18
|
+
client = new_store
|
19
|
+
(1..31).each do |j|
|
20
|
+
client['shared_key'].should == 'shared_val'
|
21
|
+
client["key-\#{j}-\#{i}"] = "val-\#{j}-\#{i}"
|
22
|
+
client["key-\#{j}-\#{i}"].should == "val-\#{j}-\#{i}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
threads.map(&:join)
|
27
|
+
end
|
12
28
|
end
|
@@ -1,7 +1,204 @@
|
|
1
|
-
|
1
|
+
require_relative '../faraday_helper.rb'
|
2
|
+
|
3
|
+
describe 'adapter_couch', adapter: :Couch do
|
4
|
+
include_context :faraday_adapter
|
5
|
+
|
2
6
|
moneta_build do
|
3
|
-
Moneta::Adapters::Couch.new(db: 'adapter_couch')
|
7
|
+
Moneta::Adapters::Couch.new(db: 'adapter_couch', adapter: faraday_adapter, login: couch_login, password: couch_password)
|
4
8
|
end
|
5
9
|
|
6
10
|
moneta_specs ADAPTER_SPECS.without_increment.simplevalues_only.without_path.with_each_key
|
11
|
+
|
12
|
+
shared_examples :batch do
|
13
|
+
shared_examples :no_batch do
|
14
|
+
it "does not add 'batch=ok' to the query'" do
|
15
|
+
expect(store).not_to receive(:request).with(any_args, hash_including(query: hash_including(batch: 'ok')))
|
16
|
+
expect(store).to receive(:request)
|
17
|
+
store.public_send(m, *args, options)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'without a :batch option' do
|
22
|
+
let(:options) { {} }
|
23
|
+
include_examples(:no_batch)
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'with batch: false' do
|
27
|
+
let(:options) { { batch: false } }
|
28
|
+
include_examples(:no_batch)
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with batch: true' do
|
32
|
+
let(:options) { { batch: true } }
|
33
|
+
|
34
|
+
it "adds 'batch=ok' to the query'" do
|
35
|
+
expect(store).to receive(:request).with(instance_of(Symbol), instance_of(String), any_args,
|
36
|
+
hash_including(expect: 202, query: hash_including(batch: 'ok')))
|
37
|
+
store.public_send(m, *args, options)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
shared_examples :full_commit do
|
43
|
+
context 'without a :full_commit option' do
|
44
|
+
let(:options) { {} }
|
45
|
+
|
46
|
+
it "does not add a 'X-Couch-Full-Commit' header'" do
|
47
|
+
expect(store).not_to receive(:request)
|
48
|
+
.with(any_args, hash_including(headers: hash_including('X-Couch-Full-Commit' => instance_of(String))))
|
49
|
+
expect(store).to receive(:request).ordered
|
50
|
+
store.public_send(m, *args, options)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'with full_commit: true' do
|
55
|
+
let(:options) { { full_commit: true } }
|
56
|
+
|
57
|
+
it "adds 'X-Couch-Full-Commit: true' to the headers'" do
|
58
|
+
expect(store).to receive(:request)
|
59
|
+
.with(instance_of(Symbol), instance_of(String), any_args,
|
60
|
+
hash_including(headers: hash_including('X-Couch-Full-Commit' => 'true')))
|
61
|
+
.ordered
|
62
|
+
store.public_send(m, *args, options)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'with full_commit: false' do
|
67
|
+
let(:options) { { full_commit: false } }
|
68
|
+
|
69
|
+
it "adds 'X-Couch-Full-Commit: false' to the headers'" do
|
70
|
+
expect(store).to receive(:request)
|
71
|
+
.with(instance_of(Symbol), instance_of(String), any_args,
|
72
|
+
hash_including(headers: hash_including('X-Couch-Full-Commit' => 'false')))
|
73
|
+
.ordered
|
74
|
+
store.public_send(m, *args, options)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#store' do
|
80
|
+
let(:m) { :store }
|
81
|
+
let(:args) { ['a', 'b'] }
|
82
|
+
|
83
|
+
include_examples :batch
|
84
|
+
include_examples :full_commit
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#delete' do
|
88
|
+
let(:m) { :delete }
|
89
|
+
let(:args) { ['a'] }
|
90
|
+
|
91
|
+
before do
|
92
|
+
expect(store).to receive(:request).with(:get, 'a', any_args).ordered do
|
93
|
+
Faraday::Response.new(
|
94
|
+
Faraday::Env.from(status: 200,
|
95
|
+
body: '{"type":"Hash","test":1}',
|
96
|
+
response_headers: { 'ETag' => '"testrev"' }))
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
include_examples :batch
|
101
|
+
include_examples :full_commit
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '#merge!' do
|
105
|
+
let(:m) { :merge! }
|
106
|
+
let(:args) { [{'a' => '1'}] }
|
107
|
+
|
108
|
+
before do
|
109
|
+
expect(store).to receive(:request).with(:post, '_all_docs', any_args).ordered do
|
110
|
+
{ 'rows' => [] }
|
111
|
+
end
|
112
|
+
|
113
|
+
allow(store).to receive(:request).with(:post, '_bulk_docs', any_args) do
|
114
|
+
[
|
115
|
+
{
|
116
|
+
"ok" => true,
|
117
|
+
"id" => 'a',
|
118
|
+
"rev" => 'testrev'
|
119
|
+
}
|
120
|
+
]
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
include_examples :full_commit
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '#clear' do
|
128
|
+
context 'changing full commit behaviour' do
|
129
|
+
let(:m) { :clear }
|
130
|
+
let(:args) { [] }
|
131
|
+
|
132
|
+
# This will make the clear method proceed to deletion
|
133
|
+
before do
|
134
|
+
responses = [
|
135
|
+
{
|
136
|
+
'rows' => [
|
137
|
+
{
|
138
|
+
'id' => 'test',
|
139
|
+
'value' => {
|
140
|
+
'rev' => 'testrev'
|
141
|
+
}
|
142
|
+
}
|
143
|
+
]
|
144
|
+
},
|
145
|
+
{ 'rows' => [] }
|
146
|
+
]
|
147
|
+
|
148
|
+
expect(store).to receive(:request).at_least(:once).with(:get, '_all_docs', any_args).ordered do
|
149
|
+
responses.shift
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
include_examples :full_commit
|
154
|
+
end
|
155
|
+
|
156
|
+
shared_examples :no_compact do
|
157
|
+
it 'does not post to the _compact endpoint' do
|
158
|
+
expect(store).not_to receive(:post).with('_compact', any_args)
|
159
|
+
store.clear(options)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
context 'without a :compact option' do
|
164
|
+
let(:options) { {} }
|
165
|
+
include_examples :no_compact
|
166
|
+
end
|
167
|
+
|
168
|
+
context 'with compact: true' do
|
169
|
+
it 'posts to the _compact endpoint' do
|
170
|
+
expect(store).to receive(:post).with('_compact', any_args)
|
171
|
+
store.clear(compact: true)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
context 'with compact: false' do
|
176
|
+
let(:options) { { compact: false } }
|
177
|
+
include_examples :no_compact
|
178
|
+
end
|
179
|
+
|
180
|
+
context 'with await_compact: true' do
|
181
|
+
it "waits for compaction to complete" do
|
182
|
+
# This simulates an empty DB, so no deletes
|
183
|
+
expect(store).to receive(:get).with('_all_docs', any_args).ordered { { 'rows' => [] } }
|
184
|
+
|
185
|
+
# Next, compact is called.
|
186
|
+
expect(store).to receive(:post).with('_compact', any_args).ordered
|
187
|
+
|
188
|
+
# We expect the method to call get the DB info as many times as the true value is returned.
|
189
|
+
expect(store).to receive(:get).twice.with('', any_args).ordered { { 'compact_running' => true } }
|
190
|
+
expect(store).to receive(:get).once.with('', any_args).ordered { { 'compact_running' => false } }
|
191
|
+
store.clear(compact: true, await_compact: true)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
context 'with await_compact: false' do
|
196
|
+
it "does not wait for compaction to complete" do
|
197
|
+
expect(store).to receive(:get).with('_all_docs', any_args).ordered { { 'rows' => [] } }
|
198
|
+
expect(store).to receive(:post).with('_compact', any_args).ordered
|
199
|
+
expect(store).not_to receive(:get).with('', any_args).ordered
|
200
|
+
store.clear(compact: true, await_compact: false)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
7
204
|
end
|
@@ -1,9 +1,15 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../faraday_helper.rb'
|
2
|
+
|
3
|
+
describe "standard_couch", adapter: :Couch do
|
4
|
+
include_context :faraday_adapter
|
5
|
+
|
6
|
+
moneta_store :Couch do
|
7
|
+
{ db: 'standard_couch', adapter: faraday_adapter, login: couch_login, password: couch_password }
|
8
|
+
end
|
3
9
|
|
4
10
|
moneta_loader do |value|
|
5
11
|
::Marshal.load(value.unpack('m').first)
|
6
12
|
end
|
7
13
|
|
8
|
-
moneta_specs STANDARD_SPECS.without_increment
|
14
|
+
moneta_specs STANDARD_SPECS.without_increment.with_each_key
|
9
15
|
end
|
@@ -1,13 +1,19 @@
|
|
1
|
+
require_relative '../faraday_helper.rb'
|
2
|
+
|
1
3
|
describe "standard_couch_with_expires", adapter: :Couch do
|
2
4
|
let(:t_res) { 0.125 }
|
3
5
|
let(:min_ttl) { t_res }
|
4
6
|
use_timecop
|
5
7
|
|
6
|
-
|
8
|
+
include_context :faraday_adapter
|
9
|
+
|
10
|
+
moneta_store :Couch do
|
11
|
+
{ db: 'standard_couch_with_expires', adapter: faraday_adapter, expires: true, login: couch_login, password: couch_password }
|
12
|
+
end
|
7
13
|
|
8
14
|
moneta_loader do |value|
|
9
15
|
::Marshal.load(value.unpack('m').first)
|
10
16
|
end
|
11
17
|
|
12
|
-
moneta_specs STANDARD_SPECS.without_increment.with_expires
|
18
|
+
moneta_specs STANDARD_SPECS.without_increment.with_expires.with_each_key
|
13
19
|
end
|
@@ -7,5 +7,5 @@ describe 'standard_daybreak_with_expires', adapter: :Daybreak do
|
|
7
7
|
{file: File.join(tempdir, "simple_daybreak_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_gdbm_with_expires', adapter: :GDBM do
|
|
7
7
|
{file: File.join(tempdir, "simple_gdbm_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
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe 'adapter_kyotocabinet', unsupported: defined?(JRUBY_VERSION), adapter: :KyotoCabinet do
|
1
|
+
describe 'adapter_kyotocabinet', unsupported: defined?(JRUBY_VERSION) || ::Gem::Version.new(RUBY_ENGINE_VERSION) >= ::Gem::Version.new('2.7.0'), adapter: :KyotoCabinet do
|
2
2
|
moneta_build do
|
3
3
|
Moneta::Adapters::KyotoCabinet.new(file: File.join(tempdir, "adapter_kyotocabinet.kch"))
|
4
4
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
describe 'standard_kyotocabinet', unsupported: defined?(JRUBY_VERSION), adapter: :KyotoCabinet do
|
1
|
+
describe 'standard_kyotocabinet', unsupported: defined?(JRUBY_VERSION) || ::Gem::Version.new(RUBY_ENGINE_VERSION) >= ::Gem::Version.new('2.7.0'), adapter: :KyotoCabinet do
|
2
2
|
moneta_store :KyotoCabinet do
|
3
3
|
{file: File.join(tempdir, "simple_kyotocabinet.kch")}
|
4
4
|
end
|
5
5
|
|
6
|
-
moneta_specs STANDARD_SPECS.without_multiprocess
|
6
|
+
moneta_specs STANDARD_SPECS.without_multiprocess.with_each_key
|
7
7
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe 'standard_kyotocabinet_with_expires', unsupported: defined?(JRUBY_VERSION), adapter: :KyotoCabinet do
|
1
|
+
describe 'standard_kyotocabinet_with_expires', unsupported: defined?(JRUBY_VERSION)|| ::Gem::Version.new(RUBY_ENGINE_VERSION) >= ::Gem::Version.new('2.7.0'), adapter: :KyotoCabinet do
|
2
2
|
let(:t_res) { 0.125 }
|
3
3
|
let(:min_ttl) { t_res }
|
4
4
|
use_timecop
|
@@ -10,5 +10,5 @@ describe 'standard_kyotocabinet_with_expires', unsupported: defined?(JRUBY_VERSI
|
|
10
10
|
}
|
11
11
|
end
|
12
12
|
|
13
|
-
moneta_specs STANDARD_SPECS.without_multiprocess.with_expires
|
13
|
+
moneta_specs STANDARD_SPECS.without_multiprocess.with_expires.with_each_key
|
14
14
|
end
|
@@ -7,5 +7,5 @@ describe 'standard_leveldb_with_expires', unsupported: defined?(JRUBY_VERSION),
|
|
7
7
|
{dir: File.join(tempdir, "standard_leveldb_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_lmdb_with_expires', unsupported: defined?(JRUBY_VERSION), ada
|
|
7
7
|
{dir: File.join(tempdir, "simple_lmdb_with_expires"), expires: true}
|
8
8
|
end
|
9
9
|
|
10
|
-
moneta_specs STANDARD_SPECS.without_concurrent.with_expires
|
10
|
+
moneta_specs STANDARD_SPECS.without_concurrent.with_expires.with_each_key
|
11
11
|
end
|
@@ -11,9 +11,9 @@ describe 'adapter_lruhash', adapter: :LRUHash do
|
|
11
11
|
(1..1000).each do |i|
|
12
12
|
store[i] = 'x'
|
13
13
|
store[0].should == 'y'
|
14
|
-
store.instance_variable_get(:@
|
14
|
+
store.instance_variable_get(:@backend).size.should == [10, i+1].min
|
15
15
|
(0...[9, i-1].min).each do |j|
|
16
|
-
store.instance_variable_get(:@
|
16
|
+
store.instance_variable_get(:@backend)[i-j].should_not be_nil
|
17
17
|
end
|
18
18
|
store.key?(i-9).should be false if i > 9
|
19
19
|
end
|