lmdb 0.6.5 → 0.6.6
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 +42 -8
- data/lib/lmdb/version.rb +1 -1
- data/spec/lmdb_spec.rb +2 -0
- 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: fcfc5ce25df41f83029918b757006f4f34b674f41c2c2691cc40128a7e63a46e
|
|
4
|
+
data.tar.gz: 9cf681ab6dc945eac9b8225717248f42cf27940a704e951aed3dbd59f151df23
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 888eb18fa7e8be017e950f1b8893fc9c4f3c4cc1fa616312438b23be86344cfdeb37d2cc7edc477a528292776ae45e95c0f65c8cd49cd417a4be387f1dd3a28f
|
|
7
|
+
data.tar.gz: 07740710e001f491d22b902d27c1e446d2bab1b93e42d41951e47fdd084b5d5f982dadc551f13764146e8725b8dda4b7a7084c2781454bac2d9f332e16fd666e
|
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,19 +134,53 @@ module LMDB
|
|
|
134
134
|
ret
|
|
135
135
|
end
|
|
136
136
|
|
|
137
|
+
# Conditionally put a value into the database.
|
|
138
|
+
#
|
|
139
|
+
# @param key [String] The key of the record
|
|
140
|
+
# @param value [String] the (optional) value
|
|
141
|
+
# @param options [Hash] options
|
|
142
|
+
#
|
|
143
|
+
# @see #put
|
|
144
|
+
#
|
|
145
|
+
# @return [void]
|
|
146
|
+
def put?(key, value = nil, **options)
|
|
147
|
+
begin
|
|
148
|
+
put key, value, **options
|
|
149
|
+
rescue LMDB::Error::KEYEXIST
|
|
150
|
+
nil
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
137
154
|
# Delete the key (and optional value pair) if it exists; do not
|
|
138
155
|
# complain about missing keys.
|
|
139
|
-
# @param key [#to_s] The key
|
|
140
|
-
# @param value [#to_s] The optional value
|
|
141
|
-
|
|
142
|
-
|
|
156
|
+
# @param key [#to_s] The key of the record
|
|
157
|
+
# @param value [#to_s] The optional value
|
|
158
|
+
#
|
|
159
|
+
# @see #delete
|
|
160
|
+
#
|
|
161
|
+
# @return [void]
|
|
162
|
+
#
|
|
163
|
+
def delete?(key, value = nil, **options)
|
|
164
|
+
begin
|
|
165
|
+
delete key, value, **options
|
|
166
|
+
rescue LMDB::Error::NOTFOUND
|
|
167
|
+
nil
|
|
168
|
+
end
|
|
143
169
|
end
|
|
144
170
|
|
|
171
|
+
# Return how many records there are in this database.
|
|
172
|
+
#
|
|
145
173
|
# @return the number of records in this database
|
|
146
174
|
def size
|
|
147
175
|
stat[:entries]
|
|
148
176
|
end
|
|
149
177
|
|
|
178
|
+
#
|
|
179
|
+
# @return whether the database is empty
|
|
180
|
+
def empty?
|
|
181
|
+
stat[:entries] == 0
|
|
182
|
+
end
|
|
183
|
+
|
|
150
184
|
private
|
|
151
185
|
|
|
152
186
|
# having trouble with read-only transactions embedded in
|
data/lib/lmdb/version.rb
CHANGED
data/spec/lmdb_spec.rb
CHANGED
|
@@ -392,6 +392,8 @@ describe LMDB do
|
|
|
392
392
|
c.set('key1', 'value3').should == nil
|
|
393
393
|
end
|
|
394
394
|
|
|
395
|
+
dupdb.put?('key1', 'value1', nodupdata: true).should be_nil
|
|
396
|
+
|
|
395
397
|
# this is basically an extended test of `cursor.set key, val`
|
|
396
398
|
dupdb.has?('key1', 'value1').should == true
|
|
397
399
|
dupdb.has?('key1', 'value2').should == true
|
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.6
|
|
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-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|