large_object_store 1.4.0 → 1.5.0

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: b62700b782559354a063c7b1f27d1a40fed24618ac7203e62f433a33ded2b46e
4
- data.tar.gz: cfe940d1f9cbecbf8bb4619afc7604775f80a215580af336e57e98f88595cd44
3
+ metadata.gz: 92be121f082879185822f734dd5fe7935ce04aacb05e900ce4dbfe89b23d712c
4
+ data.tar.gz: 14854eba125bd1837eb444ec25d65da9ae99228455f600bb4c9cb38902d3ac8a
5
5
  SHA512:
6
- metadata.gz: 875bfaffed85fb6b1d7476b9d82d8c588aedb93f01c7844bfd8518e311930b4ea466aa787ad75860d47f91614e17ce6cb3fcefb18db52855cf33df589ad1e4e6
7
- data.tar.gz: 45b2baa7dbfb379f5b7d66e0c492aa2d7dff696b1e5d690942dfb53061c4fd1267eebe0eeca78446957309b9f1526405de38a416dcec5bff8c5a24451cbcafcd
6
+ metadata.gz: 489ecb7a501deda4f45feb995585999717a595ef6e4539641a6866215d23cf89eb3f745aac02d3b95a4581356405acb21f40f79b010954a3a037cd053172fe5d
7
+ data.tar.gz: 6c8ad1eead221be4324a5d6557926b8702469797448d68e62a19ded103ad52a0a1dc146599d2f69b1dd6ab5b237659e275d07f9a1542b9aa7a735dc5bb95acf3
@@ -1,3 +1,3 @@
1
1
  module LargeObjectStore
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -14,8 +14,11 @@ module LargeObjectStore
14
14
  RAW = 2
15
15
  FLAG_RADIX = 32 # we can store 32 different states
16
16
 
17
- def self.wrap(store, **options)
18
- RailsWrapper.new(store, options)
17
+ def self.wrap(*args)
18
+ RailsWrapper.new(*args)
19
+ end
20
+ class << self
21
+ ruby2_keywords :wrap if respond_to?(:ruby2_keywords, true)
19
22
  end
20
23
 
21
24
  class RailsWrapper
@@ -26,9 +29,9 @@ module LargeObjectStore
26
29
  @serializer = serializer
27
30
  end
28
31
 
29
- def write(key, value, options = {})
32
+ def write(key, value, **options)
30
33
  options = options.dup
31
- value = serialize(value, options)
34
+ value = serialize(value, **options)
32
35
 
33
36
  # calculate slice size; note that key length is a factor because
34
37
  # the key is stored on the same slab page as the value
@@ -38,11 +41,11 @@ module LargeObjectStore
38
41
  pages = (value.size / slice_size.to_f).ceil
39
42
 
40
43
  if pages == 1
41
- !!@store.write(key(key, 0), value, options)
44
+ !!@store.write(key(key, 0), value, **options)
42
45
  else
43
46
  # store meta
44
47
  uuid = SecureRandom.hex(UUID_BYTES)
45
- return false unless @store.write(key(key, 0), [pages, uuid], options) # invalidates the old cache
48
+ return false unless @store.write(key(key, 0), [pages, uuid], **options) # invalidates the old cache
46
49
 
47
50
  # store object
48
51
  page = 1
@@ -50,7 +53,7 @@ module LargeObjectStore
50
53
  slice = value.slice!(0, slice_size)
51
54
  break if slice.size == 0
52
55
 
53
- return false unless @store.write(key(key, page), slice.prepend(uuid), options.merge(raw: true))
56
+ return false unless @store.write(key(key, page), slice.prepend(uuid), raw: true, **options)
54
57
  page += 1
55
58
  end
56
59
  true
@@ -84,11 +87,11 @@ module LargeObjectStore
84
87
  deserialize(data)
85
88
  end
86
89
 
87
- def fetch(key, options={})
90
+ def fetch(key, **options)
88
91
  value = read(key)
89
92
  return value unless value.nil?
90
93
  value = yield
91
- write(key, value, options)
94
+ write(key, value, **options)
92
95
  value
93
96
  end
94
97
 
@@ -104,7 +107,7 @@ module LargeObjectStore
104
107
 
105
108
  # convert a object to a string
106
109
  # modifies options
107
- def serialize(value, options)
110
+ def serialize(value, **options)
108
111
  flag = NORMAL
109
112
 
110
113
  if options.delete(:raw)
@@ -114,7 +117,7 @@ module LargeObjectStore
114
117
  value = @serializer.dump(value)
115
118
  end
116
119
 
117
- if compress?(value, options)
120
+ if compress?(value, **options)
118
121
  flag |= COMPRESSED
119
122
  value = Zlib::Deflate.deflate(value)
120
123
  end
@@ -132,7 +135,7 @@ module LargeObjectStore
132
135
  end
133
136
 
134
137
  # Don't pass compression on to Rails, we're doing it ourselves.
135
- def compress?(value, options)
138
+ def compress?(value, **options)
136
139
  return unless options.delete(:compress)
137
140
  compress_limit = options.delete(:compress_limit) || DEFAULT_COMPRESS_LIMIT
138
141
  value.bytesize > compress_limit
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: large_object_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ana Martinez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-16 00:00:00.000000000 Z
11
+ date: 2023-03-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: acemacu@gmail.com
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  - !ruby/object:Gem::Version
39
39
  version: '0'
40
40
  requirements: []
41
- rubygems_version: 3.1.6
41
+ rubygems_version: 3.0.3.1
42
42
  signing_key:
43
43
  specification_version: 4
44
44
  summary: Store large objects in memcache or others