rails-brotli-cache 0.3.6 → 0.3.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: 2d61874a96a2402ac69abd17762f98531de0a5b2c2749447f3c34d03dc76b57b
4
- data.tar.gz: dff930d1caf6e592d207db48ffb175ebcd06bc59d228a9b5a78e3185672ee72d
3
+ metadata.gz: 80eea251ed8707e59e4f8a9b829c7046dd9343edcd045e4ef83aa840d8fc5fae
4
+ data.tar.gz: fbe018c38651848f9aba05d3b59e96c802b7afddc36099cc8d5a5a1099fd3975
5
5
  SHA512:
6
- metadata.gz: f3d3cda105423ff917c8b7bd1785cbad9c4577fe773d9573995f1341a6fb3093538e67febe45e6c4449c80398c5edfc95770c7b968fae78524f55bdefa92bd92
7
- data.tar.gz: b705720c468a0c85e2b7cf3ff72a2c320ab0beefa3d0889c862b716d1d8d26146e5f2afe9f08bb2101e0ddc07e313cf06a85095f6b778ab8d11ef3f4977a4783
6
+ metadata.gz: c4b1622f27a59b6b46067a5ee1d354a0696029e6ebdd71b8be913c59f021251a9862600b08ed12fb7111c7a9183bc07903227a3dc0f3d9ee1563e60de0546dc8
7
+ data.tar.gz: 80a043902519762f273c65ce864ed0c9e64397c72a3a750f513e335502b46e7c1876a8d28653147db01b4762ba28be3c8f2dd4657e06671d140959a4aa0f3c09
@@ -91,7 +91,29 @@ module RailsBrotliCache
91
91
  Marshal.load(serialized)
92
92
  end
93
93
 
94
- def exist?(name, options = nil)
94
+ def write_multi(hash, options = nil)
95
+ hash.each do |key, val|
96
+ write(key, val, options)
97
+ end
98
+ end
99
+
100
+ def read_multi(*names)
101
+ options = names.extract_options!
102
+
103
+ Hash[names.map do |name|
104
+ [name, read(name, options)]
105
+ end]
106
+ end
107
+
108
+ def fetch_multi(*names)
109
+ options = names.extract_options!
110
+
111
+ names.each do |name|
112
+ fetch(name, options) { yield(name) }
113
+ end
114
+ end
115
+
116
+ def exist?(name, options = nil)
95
117
  @core_store.exist?(cache_key(name), options)
96
118
  end
97
119
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsBrotliCache
4
- VERSION = "0.3.6"
4
+ VERSION = "0.3.7"
5
5
  end
@@ -60,6 +60,46 @@ describe RailsBrotliCache do
60
60
  expect(brotli_store.fetch("val_key", force: true) { val }).to eq(standard_cache.fetch("val_key", force: true) { val })
61
61
  expect(brotli_store.fetch("val_key")).to eq(standard_cache.fetch("val_key"))
62
62
  end
63
+
64
+ it "for #write_multi and #read_multi" do
65
+ if standard_cache.class != ActiveSupport::Cache::NullStore ## NullStore does not support read/write multi
66
+ values = {
67
+ "key_1" => "val_1",
68
+ "key_2" => "val_2"
69
+ }
70
+
71
+ brotli_store.write_multi(values)
72
+ standard_cache.write_multi(values)
73
+ expect(brotli_store.read("key_1")).to eq "val_1"
74
+ expect(brotli_store.read("key_2")).to eq "val_2"
75
+ expect(standard_cache.read("key_1")).to eq "val_1"
76
+ expect(standard_cache.read("key_2")).to eq "val_2"
77
+
78
+ expect(brotli_store.read_multi("key_1", "key_2")).to eq(standard_cache.read_multi("key_1", "key_2"))
79
+ end
80
+ end
81
+
82
+ it "for #fetch_multi" do
83
+ if standard_cache.class != ActiveSupport::Cache::NullStore ## NullStore does not support fetch multi
84
+ values = {
85
+ "key_1" => "val_1",
86
+ "key_2" => "val_2"
87
+ }
88
+
89
+ brotli_store.fetch_multi("key_1", "key_2") do |key|
90
+ "val_#{key.split('_').last}"
91
+ end
92
+
93
+ standard_cache.fetch_multi("key_1", "key_2") do |key|
94
+ "val_#{key.split('_').last}"
95
+ end
96
+
97
+ expect(brotli_store.read("key_1")).to eq "val_1"
98
+ expect(brotli_store.read("key_2")).to eq "val_2"
99
+
100
+ expect(brotli_store.read_multi("key_1", "key_2")).to eq(standard_cache.read_multi("key_1", "key_2"))
101
+ end
102
+ end
63
103
  end
64
104
  end
65
105
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-brotli-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-26 00:00:00.000000000 Z
11
+ date: 2023-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails