activerecord-slotted_counters 0.1.0 → 0.1.1
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/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/activerecord_slotted_counters/has_slotted_counter.rb +2 -2
- data/lib/activerecord_slotted_counters/version.rb +1 -1
- 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: 5dcee16f487cc8b48e6fb4c4b84069cc97b9647d5e710fa8d8c2e25038620815
|
4
|
+
data.tar.gz: 43b9d1432b7aa8088c1508038d8927cf4aca1e8e33e3a159a3b915b7037f8084
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9783f3d0166756156a12e2337539acca146ebb8cbec1298d3b3b06a8721c2a23c18e61bc38c2944cd2fb999f798129e30ef608c4f862fad4e3d7628573cd49d3
|
7
|
+
data.tar.gz: a6a250dd5daed59fd0495954c9220e02de57e99232d2e19f7e159d9f838d4ad6b2a90acc3ece9f466a829afc99467ec4ef096130827be9d3ba13197c665cb367
|
data/CHANGELOG.md
CHANGED
@@ -2,9 +2,14 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.1.1 (2023-01-17)
|
6
|
+
|
7
|
+
- Fix prevent double increment/decrement of native counter caches [#10](https://github.com/evilmartians/activerecord-slotted_counters/pull/10) ([@danielwestendorf][])
|
8
|
+
|
5
9
|
## 0.1.0 (2022-11-29)
|
6
10
|
|
7
11
|
- Initial release.
|
8
12
|
|
9
13
|
[@palkan]: https://github.com/palkan
|
10
14
|
[@LukinEgor]: https://github.com/LukinEgor
|
15
|
+
[@danielwestendorf]: https://github.com/danielwestendorf
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Active Record slotted counters
|
4
4
|
|
5
|
-
This gem adds **slotted counters** support to [Active Record counter cache][counter-cache]. Slotted counters help to reduce contention on a single row update in case you many concurrent operations (like updating a page views counter during traffic spikes).
|
5
|
+
This gem adds **slotted counters** support to [Active Record counter cache][counter-cache]. Slotted counters help to reduce contention on a single row update in case you have many concurrent operations (like updating a page views counter during traffic spikes).
|
6
6
|
|
7
7
|
Read more about slotted counters in [this post](https://planetscale.com/blog/the-slotted-counter-pattern).
|
8
8
|
|
@@ -13,7 +13,7 @@ module ActiveRecordSlottedCounters
|
|
13
13
|
module BelongsToAssociation
|
14
14
|
def update_counters_via_scope(klass, foreign_key, by)
|
15
15
|
counter_name = reflection.counter_cache_column
|
16
|
-
super unless klass.registered_slotted_counter? counter_name
|
16
|
+
return super unless klass.registered_slotted_counter? counter_name
|
17
17
|
|
18
18
|
klass.update_counters(foreign_key, counter_name => by, :touch => reflection.options[:touch])
|
19
19
|
end
|
@@ -182,7 +182,7 @@ module ActiveRecordSlottedCounters
|
|
182
182
|
end
|
183
183
|
|
184
184
|
def increment!(attribute, by = 1, touch: nil)
|
185
|
-
super unless self.class.registered_slotted_counter? attribute
|
185
|
+
return super unless self.class.registered_slotted_counter? attribute
|
186
186
|
|
187
187
|
self.class.update_counters(id, attribute => by, :touch => touch)
|
188
188
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-slotted_counters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Egor Lukin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|