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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d6a2b5d9eb4d0c1a93c0d807bb890ad33bd7eafe6e55d7a132796096296f078
4
- data.tar.gz: 9ef7004f7734571bebb5352a99287f1de65e3392c7490d089de959c5a3502a68
3
+ metadata.gz: fcfc5ce25df41f83029918b757006f4f34b674f41c2c2691cc40128a7e63a46e
4
+ data.tar.gz: 9cf681ab6dc945eac9b8225717248f42cf27940a704e951aed3dbd59f151df23
5
5
  SHA512:
6
- metadata.gz: bf624d2a0e988a764d1cbdd23c30fe48d249d79f855aa5cc3bb3c3c079474edc59df57a68a47aa85b723d4dc6e28621f01c529d1f09efa948d66205e392e485c
7
- data.tar.gz: a659a1329886ffd36f6c901c9db4fb64f3f463bf085d17115b2a7b2bda9bf5cf365d5ab90850043395a66566a20d56c3548fa56997563ef714a91a5c3f764202
6
+ metadata.gz: 888eb18fa7e8be017e950f1b8893fc9c4f3c4cc1fa616312438b23be86344cfdeb37d2cc7edc477a528292776ae45e95c0f65c8cd49cd417a4be387f1dd3a28f
7
+ data.tar.gz: 07740710e001f491d22b902d27c1e446d2bab1b93e42d41951e47fdd084b5d5f982dadc551f13764146e8725b8dda4b7a7084c2781454bac2d9f332e16fd666e
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # LMDB
2
2
 
3
- [![Gittip donate button](http://img.shields.io/gittip/bevry.png)](https://www.gittip.com/min4d/ "Donate weekly to this project using Gittip")
4
- [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](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/minad/lmdb>
19
- * Bugs: <http://github.com/minad/lmdb/issues>
20
- * Tests and benchmarks: <http://travis-ci.org/minad/lmdb>
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
- If you want to have a simpler interface to LMDB databases please consider using [Moneta](https://github.com/minad/moneta). The Moneta gem provides an LMDB adapter which uses this gem.
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 (c) 2013 Daniel Mendler
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
@@ -936,7 +936,7 @@ static VALUE environment_databases(VALUE self) {
936
936
  char *intern_db_name;
937
937
  MDB_dbi db;
938
938
  VALUE db_name;
939
-
939
+
940
940
  if (memchr(key.mv_data, '\0', key.mv_size))
941
941
  continue;
942
942
 
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
- method = :set
88
- while rec = c.send(method, key)
89
- method = :next_range
90
- yield rec[1]
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
- def delete?(key, value = nil)
142
- delete key, value if has? key, value
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
@@ -1,3 +1,3 @@
1
1
  module LMDB
2
- VERSION = '0.6.5'.freeze
2
+ VERSION = '0.6.6'.freeze
3
3
  end
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.5
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-05-07 00:00:00.000000000 Z
11
+ date: 2025-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake