incrdecr_cached_counts 1.0.2 → 1.0.3
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/lib/cached_counts/version.rb +1 -1
- data/lib/cached_counts.rb +4 -12
- metadata +4 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 787795a7c9bd59e8a1163b8a1b0865607606e6670b40f646e786efee72ff3d12
|
4
|
+
data.tar.gz: b99c1eb114d83506b6e19af822f324a424ff49c9c4f7fb304ea0097407ade46d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6762bf048717294e9039485308b2ed15db8b9f94e9f6653b56aab402d75021b88b7074af9a43db3519c4d294fdfab3a38e831f28ac25ff786ef0613c3e5db9fe
|
7
|
+
data.tar.gz: 766cb4cff090a49c4752c14624b39447ca51d908634ec6abeeaaaa6a3be1c1e1353a6a98a72736d2baf8600542e8ced8134f29a5d9ac10b1037354f69bb852e3
|
data/lib/cached_counts.rb
CHANGED
@@ -288,23 +288,15 @@ module CachedCounts
|
|
288
288
|
def add_counting_hooks(attribute_name, key_getter, counted_class, options)
|
289
289
|
increment_hook = "increment_#{attribute_name}_count".to_sym
|
290
290
|
counted_class.send :define_method, increment_hook do
|
291
|
-
if (key = instance_exec &key_getter)
|
292
|
-
Rails.cache.increment(
|
293
|
-
key,
|
294
|
-
1,
|
295
|
-
initial: nil # Increment only if the key already exists
|
296
|
-
)
|
291
|
+
if (key = instance_exec &key_getter) && Rails.cache.exist?(key, raw: true)
|
292
|
+
Rails.cache.increment(key)
|
297
293
|
end
|
298
294
|
end
|
299
295
|
|
300
296
|
decrement_hook = "decrement_#{attribute_name}_count".to_sym
|
301
297
|
counted_class.send :define_method, decrement_hook do
|
302
|
-
if (key = instance_exec &key_getter)
|
303
|
-
Rails.cache.decrement(
|
304
|
-
key,
|
305
|
-
1,
|
306
|
-
initial: nil # Decrement only if the key already exists
|
307
|
-
)
|
298
|
+
if (key = instance_exec &key_getter) && Rails.cache.exist?(key, raw: true)
|
299
|
+
Rails.cache.decrement(key)
|
308
300
|
end
|
309
301
|
end
|
310
302
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incrdecr_cached_counts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Judd
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 2025-07-10 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rails
|
@@ -141,16 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
|
-
rubygems_version: 3.6.
|
144
|
+
rubygems_version: 3.6.3
|
145
145
|
specification_version: 4
|
146
146
|
summary: A replacement for Rails' counter caches using memcached (via Dalli)
|
147
|
-
test_files:
|
148
|
-
- spec/caches_count_of_spec.rb
|
149
|
-
- spec/caches_count_where_spec.rb
|
150
|
-
- spec/database.yml
|
151
|
-
- spec/fixtures.rb
|
152
|
-
- spec/fixtures/department.rb
|
153
|
-
- spec/fixtures/following.rb
|
154
|
-
- spec/fixtures/university.rb
|
155
|
-
- spec/fixtures/user.rb
|
156
|
-
- spec/spec_helper.rb
|
147
|
+
test_files: []
|