isomorfeus-hamster 0.6.4 → 0.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/isomorfeus/hamster/database.rb +6 -6
- data/lib/isomorfeus/hamster/marshal.rb +17 -9
- data/lib/isomorfeus/hamster/version.rb +1 -1
- data/lib/isomorfeus-hamster.rb +1 -0
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6647b48df1cbfd2b0a5693a20e95900c794c648a2df1bfc25952d4d7963f236
|
4
|
+
data.tar.gz: e24eedaf778490c7bc6d296343e3f205e52c56f6d2025f4276b29d8b28c93dd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f579bce116810735405fb5461c033a9d759207d748c0d3ec8b5fbcc07200c830f52064b64367d3f5c69c7a7d0268cb38c680f76a0d7e35dbc3a56ccf0a93712
|
7
|
+
data.tar.gz: 76782f3ecf8405d09a5913332d969f9a96adbc20a6d5cbfd8cf5781eac56aea2749f0969479d5bd73658ec507e673f776d5581d20b86da0c6248948cf72fd8e8
|
data/README.md
CHANGED
@@ -11,8 +11,8 @@ module Isomorfeus
|
|
11
11
|
# key, value = record
|
12
12
|
# puts "at #{key}: #{value}"
|
13
13
|
# end
|
14
|
-
def each
|
15
|
-
env.transaction
|
14
|
+
def each(readonly: true)
|
15
|
+
env.transaction readonly do
|
16
16
|
cursor do |c|
|
17
17
|
while i = c.next
|
18
18
|
yield(i)
|
@@ -54,9 +54,9 @@ module Isomorfeus
|
|
54
54
|
#
|
55
55
|
# @yield key [String] the next key in the database.
|
56
56
|
# @return [Enumerator] in lieu of a block.
|
57
|
-
def each_key(&block)
|
57
|
+
def each_key(readonly: true, &block)
|
58
58
|
return enum_for :each_key unless block_given?
|
59
|
-
env.transaction
|
59
|
+
env.transaction readonly do
|
60
60
|
cursor do |c|
|
61
61
|
while (rec = c.next true)
|
62
62
|
yield rec.first
|
@@ -71,7 +71,7 @@ module Isomorfeus
|
|
71
71
|
# @param key [#to_s] The key in question.
|
72
72
|
# @yield value [String] the next value associated with the key.
|
73
73
|
# @return [Enumerator] in lieu of a block.
|
74
|
-
def each_value(key, &block)
|
74
|
+
def each_value(key, readonly: true, &block)
|
75
75
|
return enum_for :each_value, key unless block_given?
|
76
76
|
|
77
77
|
value = get(key) or return
|
@@ -80,7 +80,7 @@ module Isomorfeus
|
|
80
80
|
return
|
81
81
|
end
|
82
82
|
|
83
|
-
env.transaction
|
83
|
+
env.transaction readonly do
|
84
84
|
cursor do |c|
|
85
85
|
method = :set
|
86
86
|
while rec = c.send(method, key)
|
@@ -2,22 +2,30 @@ module Isomorfeus
|
|
2
2
|
module Hamster
|
3
3
|
module Marshal
|
4
4
|
class << self
|
5
|
-
|
6
|
-
|
5
|
+
BROTLI = 'b:'.freeze
|
6
|
+
|
7
|
+
def dump(db, key, obj, class_cache: true, compress: false)
|
8
|
+
v = ::Oj.dump(obj, mode: :object, circular: true, class_cache: class_cache)
|
9
|
+
v = 'b:' << ::Brotli.deflate(v, quality: compress) if compress
|
10
|
+
db.env.transaction { db.put(key, v) }
|
7
11
|
end
|
8
12
|
|
9
13
|
def load(db, key, class_cache: true)
|
10
|
-
|
11
|
-
return nil unless
|
12
|
-
::
|
14
|
+
v = db.get(key)
|
15
|
+
return nil unless v
|
16
|
+
v = ::Brotli.inflate(v[2..]) if v.start_with?(BROTLI)
|
17
|
+
::Oj.load(v, mode: :object, circular: true, class_cache: class_cache)
|
13
18
|
end
|
14
19
|
|
15
|
-
def serialize(obj, class_cache: true)
|
16
|
-
::Oj.dump(obj, mode: :object, class_cache: class_cache)
|
20
|
+
def serialize(obj, class_cache: true, compress: false)
|
21
|
+
v = ::Oj.dump(obj, mode: :object, circular: true, class_cache: class_cache)
|
22
|
+
v = 'b:' << ::Brotli.deflate(v, quality: compress) if compress
|
23
|
+
v
|
17
24
|
end
|
18
25
|
|
19
|
-
def unserialize(
|
20
|
-
::
|
26
|
+
def unserialize(v, class_cache: true)
|
27
|
+
v = ::Brotli.inflate(v[2..]) if v.start_with?(BROTLI)
|
28
|
+
::Oj.load(v, mode: :object, circular: true, class_cache: class_cache)
|
21
29
|
end
|
22
30
|
end
|
23
31
|
end
|
data/lib/isomorfeus-hamster.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-hamster
|
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
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: brotli
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.4.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.4.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: oj
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,7 +112,7 @@ files:
|
|
98
112
|
- lib/isomorfeus/hamster/database.rb
|
99
113
|
- lib/isomorfeus/hamster/marshal.rb
|
100
114
|
- lib/isomorfeus/hamster/version.rb
|
101
|
-
homepage:
|
115
|
+
homepage: https://isomorfeus.com
|
102
116
|
licenses:
|
103
117
|
- MIT
|
104
118
|
metadata:
|
@@ -119,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
133
|
- !ruby/object:Gem::Version
|
120
134
|
version: '0'
|
121
135
|
requirements: []
|
122
|
-
rubygems_version: 3.3.
|
136
|
+
rubygems_version: 3.3.7
|
123
137
|
signing_key:
|
124
138
|
specification_version: 4
|
125
139
|
summary: KV store and ObjectDB for Isomorfeus.
|