rails-brotli-cache 0.3.4 → 0.3.5
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 +2 -0
- data/lib/rails-brotli-cache/store.rb +10 -0
- data/lib/rails-brotli-cache/version.rb +1 -1
- data/spec/rails-brotli-cache/store_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d2a98f625745f1051b66f22f71dfb7c284eec5d8a1087378222bea371543803
|
4
|
+
data.tar.gz: dbd97601e6ca601ffe088bbeeb2491e00fd8f34c9f363cf263228630f8cdfcc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d58c6cdd1fc0c569e7ed2d2c76584a91fcef49be8aaacfa80875b32a7995590fa441a9dfa0fd8a0dbdf554cbe95b5c2bd424358146c311a9d98a11fd3b0a3ad9
|
7
|
+
data.tar.gz: 308a8e81bd0ed6909b2dd5184a27bdcfcdbad3708e259af0f5a6c13902afb5b98f721341ad8a016d2a9935d6baf0fcb2ff9d14059aef6b5cca44c42487184884
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
This gem enables support for compressing Ruby on Rails cache entries using the [Brotli compression algorithm](https://github.com/google/brotli). `RailsBrotliCache::Store` offers better compression and performance compared to the default `Rails.cache` Gzip, regardless of the underlying data store. The gem also allows specifying any custom compression algorithm instead of Brotli.
|
4
4
|
|
5
|
+
I'm currently working on a post describing the gem in more detail. You can subscribe to [my blog's mailing list](https://eepurl.com/dhuFg5) or [follow me on Twitter](https://twitter.com/_pawurb) to get notified when it's out.
|
6
|
+
|
5
7
|
## Benchmarks
|
6
8
|
|
7
9
|
Brotli cache works as a proxy layer wrapping the standard cache data store. It applies Brotli compression instead of the default Gzip before storing cache entries.
|
@@ -72,6 +72,8 @@ module RailsBrotliCache
|
|
72
72
|
|
73
73
|
return nil unless payload.present?
|
74
74
|
|
75
|
+
return payload if payload.is_a?(Integer)
|
76
|
+
|
75
77
|
serialized = if payload.start_with?(MARK_BR_COMPRESSED)
|
76
78
|
compressor = compressor_class(options, default: @compressor_class)
|
77
79
|
compressor.inflate(payload.byteslice(1..-1))
|
@@ -94,6 +96,14 @@ module RailsBrotliCache
|
|
94
96
|
@core_store.clear
|
95
97
|
end
|
96
98
|
|
99
|
+
def increment(name, amount = 1, options = nil)
|
100
|
+
@core_store.increment(cache_key(name), amount, options)
|
101
|
+
end
|
102
|
+
|
103
|
+
def decrement(name, amount = 1, options = nil)
|
104
|
+
@core_store.decrement(cache_key(name), amount, options)
|
105
|
+
end
|
106
|
+
|
97
107
|
def self.supports_cache_versioning?
|
98
108
|
true
|
99
109
|
end
|
@@ -40,6 +40,20 @@ describe RailsBrotliCache do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
describe "#increment and #decrement" do
|
44
|
+
it "works" do
|
45
|
+
cache_store.write("integer-key", 0)
|
46
|
+
cache_store.increment("integer-key")
|
47
|
+
expect(cache_store.read("integer-key")).to eq 1
|
48
|
+
cache_store.increment("integer-key", 3)
|
49
|
+
expect(cache_store.read("integer-key")).to eq 4
|
50
|
+
cache_store.decrement("integer-key", 4)
|
51
|
+
expect(cache_store.read("integer-key")).to eq 0
|
52
|
+
cache_store.decrement("integer-key")
|
53
|
+
expect(cache_store.read("integer-key")).to eq -1
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
43
57
|
describe "exist?" do
|
44
58
|
it "returns true if cache entry exists" do
|
45
59
|
cache_store.write("test-key", 1234)
|
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.
|
4
|
+
version: 0.3.5
|
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-
|
11
|
+
date: 2023-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|