carton_db 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bbf7e47a17f6d3f6f19bb40d4a13524cc2704cd0
4
- data.tar.gz: 26098104742787b3bfa8bf0b01b8274a7cdb8e13
3
+ metadata.gz: ce323ba4a0df06b409f1b35a150a9a638740e586
4
+ data.tar.gz: b2c95dca25fe7be9c0b7c8ff7ca2f8d3ea6e7ed0
5
5
  SHA512:
6
- metadata.gz: f00b6ad528b7ec75286244bffce56ee467eeaf2e8c470a6db680e1002c242a7130b0225c77e5a4d7e853d3e1ffbfa59cdedc554e95cab6095a6c25778bbd3632
7
- data.tar.gz: 1b7c46564dae0037b6c12dfea983e4d780e2720e70a670b65ee174e08264689434ff37d7fb2c55856088375b05be1eb1e16bc8c448b2b2480d5bc3d213ebff73
6
+ metadata.gz: ed9890e79acc8c72d7005834b9ed6f8fec56ab941d9c078957cb2fa84c5e82f486ea876d981af6850bd2835ea9fc58789194e0e061087054def1a2a35ab25fdb
7
+ data.tar.gz: 69de8aac4491cd13b67c3e2bb0a707961c8a359259278303a70e094c19fe7e60b3c5c3b2983f1b6268b74bc5045f762eeb7abb53b22e031049bfa6d2e962e06c
data/README.md CHANGED
@@ -18,12 +18,12 @@ Ruby program running on Heroku to collect data into a map of
18
18
  sets of elements that would be too large to be effectively
19
19
  handled in memory. The application didn't already have any use
20
20
  for a relational database server, and I didn't want to add one
21
- just for this requirement. A redis db with sufficient capacity
21
+ just for this requirement. A Redis db with sufficient capacity
22
22
  would have been expensive, and solutions such as SQLite are
23
23
  specifically not supported by Heroku so people don't mistakenly
24
24
  expect the data to be preserved. Ruby's `PStore`, `DBM` and
25
- `SDMB` each proved to be too unpredicatable and flakey to be
26
- practical solutions.
25
+ `SDMB` each proved to be too unpredicatable and flakey to be a
26
+ practical solution.
27
27
 
28
28
  Although this tool was initially developed to store transient
29
29
  data for use within a single process invocation and then
@@ -54,7 +54,9 @@ filesystem containing the files that store the data.
54
54
  A database is accessed through an instance of a database class.
55
55
 
56
56
  An instance of a database class maintains no state in memory
57
- between calls to its methods except for the database name.
57
+ between calls to its methods except for the database name and the
58
+ expectation of a directory with that name existing in the
59
+ filesystem.
58
60
 
59
61
  An empty directory is a valid empty database.
60
62
 
@@ -66,8 +68,8 @@ attempting to do that are unpredictable.
66
68
 
67
69
  Initializing a new database class instance creates its directory
68
70
  in the filesystem if it does not already exist. The parent of the
69
- database directory is expected to already exist, and an error
70
- will occur if it doesn't.
71
+ database directory is expected to already exist, and an
72
+ exception will be raised if it doesn't.
71
73
 
72
74
  The database structure is designed to effectively handle up to
73
75
  several million elements with entries containing up to 1 or 2
@@ -87,6 +87,13 @@ module CartonDb
87
87
  ary
88
88
  end
89
89
 
90
+ # Returns true if an entry with the given key exists.
91
+ #
92
+ # Performance is similar to #[] but may be somewhat faster
93
+ # when a key is found since it doesn't need to ensure that
94
+ # it has read all of the elements for an entry.
95
+ #
96
+ # @param key [String] The key identifying the entry.
90
97
  def key?(key)
91
98
  key_d = CartonDb::Datum.for_plain(key)
92
99
  segment = segment_containing(key_d)
@@ -97,6 +104,14 @@ module CartonDb
97
104
  false
98
105
  end
99
106
 
107
+ # Returns trus if an entry with the given key exists and its
108
+ # content includes at least one element with the given
109
+ # element value.
110
+ #
111
+ # Performance is similar to #key?
112
+ #
113
+ # @param key [String] The key identifying the entry.
114
+ # @param element [String] The element value to match.
100
115
  def element?(key, element)
101
116
  key_d = CartonDb::Datum.for_plain(key)
102
117
  element_d = CartonDb::Datum.for_plain(element)
@@ -1,4 +1,4 @@
1
1
  # -*- coding: UTF-8 -*-
2
2
  module CartonDb
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carton_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Jorgensen