lmdb 0.6.5 → 0.6.7
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/README.md +9 -11
- data/ext/lmdb_ext/lmdb_ext.c +1 -1
- data/lib/lmdb/database.rb +48 -7
- data/lib/lmdb/version.rb +1 -1
- data/spec/lmdb_spec.rb +82 -76
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 79e94aae1eb049c37cc44abdde80712dd5c8fa900d1ec2b68c33b773862f4e1a
|
|
4
|
+
data.tar.gz: ccf377de1e2e910c81459fad2fe0bce8eb831ca40e3f95fc311ef7ccd3eb1e57
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0e3d55b2b4486caea098bb175b6ae4aeff87d770010ce4359c003e1707e6089da204a1f6f62fd0bf1e300170e0954b6245dc6fd3d9e951211d87f0b94cf958e8
|
|
7
|
+
data.tar.gz: 96e68bf724dfc2f47a5bfd72dbc5fcda8ede5e8b7edc69e1cb2e55f5c6230997bd319e04d47bbea8aaca39c5d0e322f70e37b2f9d0cb8f5e991b50ca7df51469
|
data/README.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# LMDB
|
|
2
2
|
|
|
3
|
-
[](https://www.gittip.com/min4d/ "Donate weekly to this project using Gittip")
|
|
4
|
-
[](https://flattr.com/submit/auto?user_id=min4d&url=https://github.com/minad/lmdb&title=LMDB&language=&tags=github&category=software)
|
|
5
|
-
|
|
6
3
|
Ruby bindings for the amazing [OpenLDAP's Lightning Memory-Mapped Database (LMDB)](https://www.symas.com/lmdb/).
|
|
7
4
|
|
|
8
5
|
## Installation
|
|
@@ -15,12 +12,9 @@ gem install lmdb
|
|
|
15
12
|
|
|
16
13
|
## Links
|
|
17
14
|
|
|
18
|
-
* Source: <http://github.com/
|
|
19
|
-
* Bugs: <http://github.com/
|
|
20
|
-
*
|
|
21
|
-
* API documentation:
|
|
22
|
-
* Latest Gem: <http://rubydoc.info/gems/lmdb/frames>
|
|
23
|
-
* GitHub master: <http://rubydoc.info/github/minad/lmdb/master/frames>
|
|
15
|
+
* Source: <http://github.com/doriantaylor/rb-lmdb>
|
|
16
|
+
* Bugs: <http://github.com/doriantaylor/rb-lmdb/issues>
|
|
17
|
+
* API documentation: <http://rubydoc.info/gems/lmdb/>
|
|
24
18
|
|
|
25
19
|
## API
|
|
26
20
|
|
|
@@ -42,12 +36,16 @@ end
|
|
|
42
36
|
env.close
|
|
43
37
|
```
|
|
44
38
|
|
|
45
|
-
|
|
39
|
+
## Moneta
|
|
40
|
+
|
|
41
|
+
If you want to have a simpler interface to LMDB databases please
|
|
42
|
+
consider using [Moneta](https://github.com/minad/moneta). The Moneta
|
|
43
|
+
gem provides an LMDB adapter which uses this gem.
|
|
46
44
|
|
|
47
45
|
## License (MIT)
|
|
48
46
|
|
|
49
47
|
```
|
|
50
|
-
Copyright
|
|
48
|
+
Copyright ©2013 Daniel Mendler (later changes ©2025 Dorian Taylor)
|
|
51
49
|
|
|
52
50
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
53
51
|
a copy of this software and associated documentation files (the
|
data/ext/lmdb_ext/lmdb_ext.c
CHANGED
data/lib/lmdb/database.rb
CHANGED
|
@@ -84,10 +84,10 @@ module LMDB
|
|
|
84
84
|
maybe_txn true do
|
|
85
85
|
# env.transaction do
|
|
86
86
|
cursor do |c|
|
|
87
|
-
|
|
88
|
-
while rec
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
rec = c.set key
|
|
88
|
+
while rec
|
|
89
|
+
yield rec.last
|
|
90
|
+
rec = c.next_range key
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
end
|
|
@@ -134,24 +134,65 @@ module LMDB
|
|
|
134
134
|
ret
|
|
135
135
|
end
|
|
136
136
|
|
|
137
|
+
# Conditionally put a value into the database.
|
|
138
|
+
#
|
|
139
|
+
# @param key [#to_s] The key of the record
|
|
140
|
+
# @param value [#to_s, nil] the (optional) value
|
|
141
|
+
# @param options [Hash] options
|
|
142
|
+
#
|
|
143
|
+
# @see #put
|
|
144
|
+
#
|
|
145
|
+
# @return [void]
|
|
146
|
+
#
|
|
147
|
+
def put?(key, value = nil, **options)
|
|
148
|
+
flags = {}
|
|
149
|
+
flags[dupsort? ? :nodupdata : :nooverwrite] = true
|
|
150
|
+
begin
|
|
151
|
+
put key, value, **options.merge(flags)
|
|
152
|
+
rescue LMDB::Error::KEYEXIST
|
|
153
|
+
nil
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
137
157
|
# Delete the key (and optional value pair) if it exists; do not
|
|
138
158
|
# complain about missing keys.
|
|
139
|
-
# @param key [#to_s] The key
|
|
140
|
-
# @param value [#to_s] The optional value
|
|
159
|
+
# @param key [#to_s] The key of the record
|
|
160
|
+
# @param value [#to_s, nil] The optional value
|
|
161
|
+
#
|
|
162
|
+
# @see #delete
|
|
163
|
+
#
|
|
164
|
+
# @return [void]
|
|
165
|
+
#
|
|
141
166
|
def delete?(key, value = nil)
|
|
142
|
-
|
|
167
|
+
begin
|
|
168
|
+
delete key, value
|
|
169
|
+
rescue LMDB::Error::NOTFOUND
|
|
170
|
+
nil
|
|
171
|
+
end
|
|
143
172
|
end
|
|
144
173
|
|
|
174
|
+
# Return how many records there are in this database.
|
|
175
|
+
#
|
|
145
176
|
# @return the number of records in this database
|
|
146
177
|
def size
|
|
147
178
|
stat[:entries]
|
|
148
179
|
end
|
|
149
180
|
|
|
181
|
+
#
|
|
182
|
+
# @return whether the database is empty
|
|
183
|
+
def empty?
|
|
184
|
+
stat[:entries] == 0
|
|
185
|
+
end
|
|
186
|
+
|
|
150
187
|
private
|
|
151
188
|
|
|
152
189
|
# having trouble with read-only transactions embedded in
|
|
153
190
|
# read-write for some reason; can't pin it down to test it yet so
|
|
154
191
|
# going to do this (djt; 2020-02-10)
|
|
192
|
+
#
|
|
193
|
+
# 2025-11-14: this miiiigght no longer be necessary?? like as of
|
|
194
|
+
# whenever i implemented that short-circuiting code
|
|
195
|
+
#
|
|
155
196
|
def maybe_txn(readonly, &block)
|
|
156
197
|
if t = env.active_txn
|
|
157
198
|
# warn "reusing #{t.readonly? ? 'read-only ' : ''}txn #{t.inspect}"
|
data/lib/lmdb/version.rb
CHANGED
data/spec/lmdb_spec.rb
CHANGED
|
@@ -40,8 +40,8 @@ describe LMDB do
|
|
|
40
40
|
env = LMDB::Environment.new(path, nosync: true, mode: 0777,
|
|
41
41
|
maxreaders: 777, mapsize: 111111, maxdbs: 666)
|
|
42
42
|
env.should be_instance_of(described_class)
|
|
43
|
-
env.info[:maxreaders].should
|
|
44
|
-
env.info[:mapsize].should
|
|
43
|
+
env.info[:maxreaders].should eq(777)
|
|
44
|
+
env.info[:mapsize].should eq(111111)
|
|
45
45
|
env.flags.should include(:nosync)
|
|
46
46
|
env.close
|
|
47
47
|
|
|
@@ -74,7 +74,7 @@ describe LMDB do
|
|
|
74
74
|
it 'should set mapsize' do
|
|
75
75
|
size_before = env.info[:mapsize]
|
|
76
76
|
env.mapsize = size_before * 2
|
|
77
|
-
env.info[:mapsize].should
|
|
77
|
+
env.info[:mapsize].should eq(size_before * 2)
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
it 'should copy' do
|
|
@@ -108,7 +108,7 @@ describe LMDB do
|
|
|
108
108
|
it 'returns list of named databases' do
|
|
109
109
|
db1 = subject.database 'db1', create: true
|
|
110
110
|
db2 = subject.database 'db2', create: true
|
|
111
|
-
subject.databases.should
|
|
111
|
+
subject.databases.should eq(['db1', 'db2'])
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
it 'returns list of named databases when there are non-database kes in the main db' do
|
|
@@ -117,7 +117,7 @@ describe LMDB do
|
|
|
117
117
|
subject.database 'db1', create: true
|
|
118
118
|
subject.database 'db2', create: true
|
|
119
119
|
|
|
120
|
-
subject.databases.should
|
|
120
|
+
subject.databases.should eq(['db1', 'db2'])
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
|
|
@@ -125,71 +125,71 @@ describe LMDB do
|
|
|
125
125
|
subject { env }
|
|
126
126
|
|
|
127
127
|
it 'should create transactions' do
|
|
128
|
-
subject.active_txn.should
|
|
128
|
+
subject.active_txn.should be_nil
|
|
129
129
|
subject.transaction do |txn|
|
|
130
|
-
subject.active_txn.should
|
|
130
|
+
subject.active_txn.should eq(txn)
|
|
131
131
|
txn.should be_instance_of(described_class)
|
|
132
132
|
txn.abort
|
|
133
|
-
subject.active_txn.should
|
|
133
|
+
subject.active_txn.should be_nil
|
|
134
134
|
end
|
|
135
|
-
subject.active_txn.should
|
|
135
|
+
subject.active_txn.should be_nil
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
it 'should create read-only transactions' do
|
|
139
|
-
subject.active_txn.should
|
|
139
|
+
subject.active_txn.should be_nil
|
|
140
140
|
subject.transaction(true) do |txn|
|
|
141
|
-
subject.active_txn.should
|
|
141
|
+
subject.active_txn.should eq(txn)
|
|
142
142
|
txn.should be_instance_of(described_class)
|
|
143
143
|
txn.abort
|
|
144
|
-
subject.active_txn.should
|
|
144
|
+
subject.active_txn.should be_nil
|
|
145
145
|
end
|
|
146
|
-
subject.active_txn.should
|
|
146
|
+
subject.active_txn.should be_nil
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
it 'can create child transactions' do
|
|
150
|
-
subject.active_txn.should
|
|
150
|
+
subject.active_txn.should be_nil
|
|
151
151
|
env.transaction do |txn|
|
|
152
|
-
subject.active_txn.should
|
|
152
|
+
subject.active_txn.should eq(txn)
|
|
153
153
|
env.transaction do |ctxn|
|
|
154
|
-
subject.active_txn.should
|
|
154
|
+
subject.active_txn.should eq(ctxn)
|
|
155
155
|
ctxn.abort
|
|
156
|
-
subject.active_txn.should
|
|
156
|
+
subject.active_txn.should eq(txn)
|
|
157
157
|
end
|
|
158
|
-
subject.active_txn.should
|
|
158
|
+
subject.active_txn.should eq(txn)
|
|
159
159
|
end
|
|
160
|
-
subject.active_txn.should
|
|
160
|
+
subject.active_txn.should be_nil
|
|
161
161
|
end
|
|
162
162
|
|
|
163
163
|
it 'should support aborting parent transaction' do
|
|
164
|
-
subject.active_txn.should
|
|
164
|
+
subject.active_txn.should be_nil
|
|
165
165
|
env.transaction do |txn|
|
|
166
|
-
subject.active_txn.should
|
|
166
|
+
subject.active_txn.should eq(txn)
|
|
167
167
|
env.transaction do |ctxn|
|
|
168
|
-
subject.active_txn.should
|
|
168
|
+
subject.active_txn.should eq(ctxn)
|
|
169
169
|
db['key'] = 'value'
|
|
170
170
|
txn.abort
|
|
171
|
-
subject.active_txn.should
|
|
171
|
+
subject.active_txn.should be_nil
|
|
172
172
|
end
|
|
173
|
-
subject.active_txn.should
|
|
173
|
+
subject.active_txn.should be_nil
|
|
174
174
|
end
|
|
175
|
-
db['key'].should
|
|
176
|
-
subject.active_txn.should
|
|
175
|
+
db['key'].should be_nil
|
|
176
|
+
subject.active_txn.should be_nil
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
it 'should support comitting parent transaction' do
|
|
180
|
-
subject.active_txn.should
|
|
180
|
+
subject.active_txn.should be_nil
|
|
181
181
|
env.transaction do |txn|
|
|
182
|
-
subject.active_txn.should
|
|
182
|
+
subject.active_txn.should eq(txn)
|
|
183
183
|
env.transaction do |ctxn|
|
|
184
|
-
subject.active_txn.should
|
|
184
|
+
subject.active_txn.should eq(ctxn)
|
|
185
185
|
db['key'] = 'value'
|
|
186
186
|
txn.commit
|
|
187
|
-
subject.active_txn.should
|
|
187
|
+
subject.active_txn.should be_nil
|
|
188
188
|
end
|
|
189
|
-
subject.active_txn.should
|
|
189
|
+
subject.active_txn.should be_nil
|
|
190
190
|
end
|
|
191
|
-
db['key'].should
|
|
192
|
-
subject.active_txn.should
|
|
191
|
+
db['key'].should eq('value')
|
|
192
|
+
subject.active_txn.should be_nil
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
it 'should get environment' do
|
|
@@ -197,7 +197,7 @@ describe LMDB do
|
|
|
197
197
|
env.transaction do |txn|
|
|
198
198
|
env2 = txn.env
|
|
199
199
|
end
|
|
200
|
-
env2.should
|
|
200
|
+
env2.should eq(env)
|
|
201
201
|
end
|
|
202
202
|
end
|
|
203
203
|
end
|
|
@@ -207,8 +207,8 @@ describe LMDB do
|
|
|
207
207
|
|
|
208
208
|
it 'should return flags' do
|
|
209
209
|
subject.flags.should be_instance_of(Hash)
|
|
210
|
-
subject.dupsort?.should
|
|
211
|
-
subject.dupfixed?.should
|
|
210
|
+
subject.dupsort?.should be_falsy
|
|
211
|
+
subject.dupfixed?.should be_falsy
|
|
212
212
|
end
|
|
213
213
|
|
|
214
214
|
it 'should support named databases' do
|
|
@@ -222,19 +222,22 @@ describe LMDB do
|
|
|
222
222
|
db1['key'] = '2'
|
|
223
223
|
db2['key'] = '3'
|
|
224
224
|
|
|
225
|
-
main['key'].should
|
|
226
|
-
db1['key'].should
|
|
227
|
-
db2['key'].should
|
|
225
|
+
main['key'].should eq(?1)
|
|
226
|
+
db1['key'].should eq(?2)
|
|
227
|
+
db2['key'].should eq(?3)
|
|
228
228
|
end
|
|
229
229
|
|
|
230
230
|
it 'should get/put data' do
|
|
231
231
|
subject.get('cat').should be_nil
|
|
232
232
|
subject.put('cat', 'garfield').should be_nil
|
|
233
|
-
subject.get('cat').should
|
|
233
|
+
subject.get('cat').should eq('garfield')
|
|
234
234
|
|
|
235
235
|
# check for key-value pairs on non-dupsort database
|
|
236
|
-
subject.has?('cat', 'garfield').should
|
|
237
|
-
subject.has?('cat', 'heathcliff').should
|
|
236
|
+
subject.has?('cat', 'garfield').should be_truthy
|
|
237
|
+
subject.has?('cat', 'heathcliff').should be_falsy
|
|
238
|
+
|
|
239
|
+
subject.put?('dog', 'odie')
|
|
240
|
+
subject.has?('dog', 'odie').should be_truthy
|
|
238
241
|
end
|
|
239
242
|
|
|
240
243
|
it 'should delete by key' do
|
|
@@ -255,7 +258,7 @@ describe LMDB do
|
|
|
255
258
|
|
|
256
259
|
it 'stores key/values in same transaction' do
|
|
257
260
|
db.put('key', 'value').should be_nil
|
|
258
|
-
db.get('key').should
|
|
261
|
+
db.get('key').should eq('value')
|
|
259
262
|
end
|
|
260
263
|
|
|
261
264
|
it 'stores key/values in different transactions' do
|
|
@@ -268,10 +271,10 @@ describe LMDB do
|
|
|
268
271
|
end
|
|
269
272
|
|
|
270
273
|
env.transaction do
|
|
271
|
-
db.get('key').should
|
|
272
|
-
db.get('key2').should
|
|
274
|
+
db.get('key').should eq('value')
|
|
275
|
+
db.get('key2').should eq('value2')
|
|
273
276
|
env.transaction do
|
|
274
|
-
db.get('key3').should
|
|
277
|
+
db.get('key3').should eq('value3')
|
|
275
278
|
end
|
|
276
279
|
end
|
|
277
280
|
end
|
|
@@ -281,22 +284,22 @@ describe LMDB do
|
|
|
281
284
|
end
|
|
282
285
|
|
|
283
286
|
it 'should return size' do
|
|
284
|
-
db.size.should
|
|
287
|
+
db.size.should eq(0)
|
|
285
288
|
db.put('key', 'value')
|
|
286
|
-
db.size.should
|
|
289
|
+
db.size.should eq(1)
|
|
287
290
|
db.put('key2', 'value2')
|
|
288
|
-
db.size.should
|
|
291
|
+
db.size.should eq(2)
|
|
289
292
|
end
|
|
290
293
|
|
|
291
294
|
it 'should be enumerable' do
|
|
292
295
|
db['k1'] = 'v1'
|
|
293
296
|
db['k2'] = 'v2'
|
|
294
|
-
db.to_a.should
|
|
297
|
+
db.to_a.should eq([['k1', 'v1'], ['k2', 'v2']])
|
|
295
298
|
end
|
|
296
299
|
|
|
297
300
|
it 'should have shortcuts' do
|
|
298
301
|
db['key'] = 'value'
|
|
299
|
-
db['key'].should
|
|
302
|
+
db['key'].should eq('value')
|
|
300
303
|
end
|
|
301
304
|
|
|
302
305
|
it 'should store binary' do
|
|
@@ -304,15 +307,15 @@ describe LMDB do
|
|
|
304
307
|
bin2 = "\xAAx\BB\xCC2"
|
|
305
308
|
db[bin1] = bin2
|
|
306
309
|
db['key'] = bin2
|
|
307
|
-
db[bin1].should
|
|
308
|
-
db['key'].should
|
|
310
|
+
db[bin1].should eq(bin2)
|
|
311
|
+
db['key'].should eq(bin2)
|
|
309
312
|
end
|
|
310
313
|
|
|
311
314
|
it 'should get environment' do
|
|
312
315
|
main = env.database
|
|
313
316
|
db1 = env.database('db1', create: true)
|
|
314
|
-
main.env.should
|
|
315
|
-
db1.env.should
|
|
317
|
+
main.env.should eq(env)
|
|
318
|
+
db1.env.should eq(env)
|
|
316
319
|
end
|
|
317
320
|
|
|
318
321
|
it 'should iterate over/list keys' do
|
|
@@ -330,38 +333,38 @@ describe LMDB do
|
|
|
330
333
|
|
|
331
334
|
it 'should get first key/value' do
|
|
332
335
|
db.cursor do |c|
|
|
333
|
-
c.first.should
|
|
336
|
+
c.first.should eq(['key1', 'value1'])
|
|
334
337
|
end
|
|
335
338
|
end
|
|
336
339
|
|
|
337
340
|
it 'should get last key/value' do
|
|
338
341
|
db.cursor do |c|
|
|
339
|
-
c.last.should
|
|
342
|
+
c.last.should eq(['key2', 'value2'])
|
|
340
343
|
end
|
|
341
344
|
end
|
|
342
345
|
|
|
343
346
|
it 'should get next key/value' do
|
|
344
347
|
db.cursor do |c|
|
|
345
348
|
c.first
|
|
346
|
-
c.next.should
|
|
349
|
+
c.next.should eq(['key2', 'value2'])
|
|
347
350
|
end
|
|
348
351
|
end
|
|
349
352
|
|
|
350
353
|
it 'should seek to key' do
|
|
351
354
|
db.cursor do |c|
|
|
352
|
-
c.set('key1').should
|
|
355
|
+
c.set('key1').should eq(['key1', 'value1'])
|
|
353
356
|
end
|
|
354
357
|
end
|
|
355
358
|
|
|
356
359
|
it 'should seek to closest key' do
|
|
357
360
|
db.cursor do |c|
|
|
358
|
-
c.set_range('key0').should
|
|
361
|
+
c.set_range('key0').should eq(['key1', 'value1'])
|
|
359
362
|
end
|
|
360
363
|
end
|
|
361
364
|
|
|
362
365
|
it 'should seek to key with nuls' do
|
|
363
366
|
db.cursor do |c|
|
|
364
|
-
c.set_range('\x00').should
|
|
367
|
+
c.set_range('\x00').should eq(['key1', 'value1'])
|
|
365
368
|
end
|
|
366
369
|
end
|
|
367
370
|
|
|
@@ -369,8 +372,8 @@ describe LMDB do
|
|
|
369
372
|
db.cursor do |c|
|
|
370
373
|
db.put('key0', 'value0')
|
|
371
374
|
c.first
|
|
372
|
-
c.next_range('key1').should
|
|
373
|
-
c.next_range('key1').should
|
|
375
|
+
c.next_range('key1').should eq(['key1', 'value1'])
|
|
376
|
+
c.next_range('key1').should be_nil
|
|
374
377
|
end
|
|
375
378
|
end
|
|
376
379
|
|
|
@@ -378,32 +381,35 @@ describe LMDB do
|
|
|
378
381
|
dupdb = env.database 'dupsort', create: true, dupsort: true
|
|
379
382
|
|
|
380
383
|
# check flag while we're at it
|
|
381
|
-
dupdb.flags[:dupsort].should
|
|
382
|
-
dupdb.dupsort?.should
|
|
383
|
-
dupdb.dupfixed?.should
|
|
384
|
+
dupdb.flags[:dupsort].should be_truthy
|
|
385
|
+
dupdb.dupsort?.should be_truthy
|
|
386
|
+
dupdb.dupfixed?.should be_falsy
|
|
384
387
|
|
|
385
388
|
# add the no-op keyword to trigger a complaint from ruby 2.7
|
|
386
389
|
dupdb.put 'key1', 'value1', nodupdata: false
|
|
387
390
|
dupdb.put 'key1', 'value2'
|
|
388
391
|
dupdb.put 'key2', 'value3'
|
|
389
392
|
dupdb.cursor do |c|
|
|
390
|
-
c.set('key1', 'value2').should
|
|
391
|
-
c.set('key1', 'value1').should
|
|
392
|
-
c.set('key1', 'value3').should
|
|
393
|
+
c.set('key1', 'value2').should eq(['key1', 'value2'])
|
|
394
|
+
c.set('key1', 'value1').should eq(['key1', 'value1'])
|
|
395
|
+
c.set('key1', 'value3').should be_nil
|
|
393
396
|
end
|
|
394
397
|
|
|
398
|
+
# this should do nothing
|
|
399
|
+
dupdb.put?('key1', 'value1', nodupdata: true).should be_nil
|
|
400
|
+
|
|
395
401
|
# this is basically an extended test of `cursor.set key, val`
|
|
396
|
-
dupdb.has?('key1', 'value1').should
|
|
397
|
-
dupdb.has?('key1', 'value2').should
|
|
398
|
-
dupdb.has?('key1', 'value0').should
|
|
402
|
+
dupdb.has?('key1', 'value1').should be_truthy
|
|
403
|
+
dupdb.has?('key1', 'value2').should be_truthy
|
|
404
|
+
dupdb.has?('key1', 'value0').should be_falsy
|
|
399
405
|
|
|
400
406
|
# match the contents of key1
|
|
401
|
-
dupdb.each_value('key1').to_a.sort.should
|
|
407
|
+
dupdb.each_value('key1').to_a.sort.should eq(['value1', 'value2'])
|
|
402
408
|
|
|
403
409
|
# we should have two entries for key1
|
|
404
|
-
dupdb.cardinality('key1').should
|
|
410
|
+
dupdb.cardinality('key1').should eq(2)
|
|
405
411
|
|
|
406
|
-
dupdb.each_key.to_a.sort.should
|
|
412
|
+
dupdb.each_key.to_a.sort.should eq(['key1', 'key2'])
|
|
407
413
|
|
|
408
414
|
# XXX move this or whatever
|
|
409
415
|
env.transaction do |t|
|
|
@@ -430,7 +436,7 @@ describe LMDB do
|
|
|
430
436
|
it 'should get database' do
|
|
431
437
|
db2 = nil
|
|
432
438
|
env.transaction { c = db.cursor; db2 = c.database }
|
|
433
|
-
db2.should
|
|
439
|
+
db2.should eq(db)
|
|
434
440
|
end
|
|
435
441
|
|
|
436
442
|
it 'should nest a read-only txn in a read-write' do
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lmdb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Mendler
|
|
8
8
|
- Dorian Taylor
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|