carton_db 1.1.0 → 1.1.1
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 +8 -6
- data/lib/carton_db/list_map_db.rb +15 -0
- data/lib/carton_db/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce323ba4a0df06b409f1b35a150a9a638740e586
|
4
|
+
data.tar.gz: b2c95dca25fe7be9c0b7c8ff7ca2f8d3ea6e7ed0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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
|
70
|
-
will
|
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)
|
data/lib/carton_db/version.rb
CHANGED