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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0a62ae4a77a996b8dc257b1f39600f1c90a2903765fb495a8ae47e70ba961c7
4
- data.tar.gz: 3fd95f68beed49e13b4f2c3dc13ffc97d9ad48beb3b62822e232c1781aee5f59
3
+ metadata.gz: a6647b48df1cbfd2b0a5693a20e95900c794c648a2df1bfc25952d4d7963f236
4
+ data.tar.gz: e24eedaf778490c7bc6d296343e3f205e52c56f6d2025f4276b29d8b28c93dd3
5
5
  SHA512:
6
- metadata.gz: aa0b2b6738eab73e3ceb690ad5fdaa8a90e2046ff6a2429dded499afe78d3286a14ec9a9a7bfae03d78a78f685b9ba24abcb84b4e276b2fb2820b59d573f8405
7
- data.tar.gz: d59d6b728565ea92591f49eb49f0c8228bcf1423fe052de117dc3b24c5f97dc70f502a7a96b422aa5fc9a8385844add878ff755745f91535fa756e664fdbf16c
6
+ metadata.gz: 3f579bce116810735405fb5461c033a9d759207d748c0d3ec8b5fbcc07200c830f52064b64367d3f5c69c7a7d0268cb38c680f76a0d7e35dbc3a56ccf0a93712
7
+ data.tar.gz: 76782f3ecf8405d09a5913332d969f9a96adbc20a6d5cbfd8cf5781eac56aea2749f0969479d5bd73658ec507e673f776d5581d20b86da0c6248948cf72fd8e8
data/README.md CHANGED
@@ -7,4 +7,4 @@
7
7
  Convenient and well performing key value store and object database.
8
8
 
9
9
  ### Community and Support
10
- At the [Isomorfeus Framework Project](http://isomorfeus.com)
10
+ At the [Isomorfeus Framework Project](https://isomorfeus.com)
@@ -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 true do
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 true do
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 true do
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
- def dump(db, key, obj, class_cache: true)
6
- db.env.transaction { db.put(key, ::Oj.dump(obj, mode: :object, class_cache: class_cache)) }
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
- obj_j = db.get(key)
11
- return nil unless obj_j
12
- ::Oj.load(obj_j, mode: :object, class_cache: class_cache)
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(obj_j, class_cache: true)
20
- ::Oj.load(obj_j, mode: :object, class_cache: class_cache)
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
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Hamster
3
- VERSION = '0.6.4'
3
+ VERSION = '0.6.7'
4
4
  end
5
5
  end
@@ -1,3 +1,4 @@
1
+ require 'brotli'
1
2
  require 'oj'
2
3
  require 'isomorfeus_hamster_ext'
3
4
  require 'isomorfeus/hamster/version'
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
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-02-08 00:00:00.000000000 Z
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: http://isomorfeus.com
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.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.