redis-objects-preloadable 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2135bc0cffef091721bc51971f69adbfbe636ef10a372758db3e4de164bf7ec9
4
- data.tar.gz: cae263e6dafa776af239cf3ce8d7a38d1f2eccbf2452b90e5a2a8afe82bf8680
3
+ metadata.gz: a44062b18cd9ef7c2fed29f9bf72f7438f319bb9383727f7c69dcf013d6c98fd
4
+ data.tar.gz: 6d9bbfafa458a31596ac7cf721852e5ea05e50ea2fe9ecb2d30c640e0e46b6e6
5
5
  SHA512:
6
- metadata.gz: 82c717b269c84a0c977b195ec5be729a177e83d00268506eb9d2efc641cf1d32938fd4f9eb9c6346746b55e11ba0b41d954051719140c7e1f99ecd54e345f085
7
- data.tar.gz: 4b96bf14d1cce588cf96500819898aa0da85468f75fce4e9b9042d6ea22bd50c25ab392def2120323e39d0b47e7a295204a674ea3af48a811e26a6e4c50706e9
6
+ metadata.gz: 8197221aca5a63029b05b0a1a7fa4a54bf8a9ac3338f1467a979016647e534fa61c80ec26b3ac2b903ef88afd1866d51619e369e70da54dded7a573b50bd9996
7
+ data.tar.gz: 9dae232377119b913f983a42e0fa999f1ccf5ee48261d231b86b4599837de0c2485937ed867f7d13c1d6e6bdcb3bb8beb3440a5df49e89aa938ae3caed991031
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.2] - 2026-02-22
4
+
5
+ - Fix `RelationExtension#reset` to clear `@redis_preload_context_attached`, so `redis_preload` context is correctly re-attached on every `load` after `reset` (matches AR `.includes` behavior)
6
+ - Document that `record.reload` does not clear preloaded Redis values (by design)
7
+
3
8
  ## [0.1.1] - 2026-02-22
4
9
 
5
10
  - Fix Rails 8.1 / Ruby 3.4 compatibility: forward all arguments in `ModelExtension.all` override to avoid `ArgumentError` when `ActiveRecord::Persistence#_find_record` calls `all(all_queries: ...)` ([#fix](https://github.com/kyohah/redis-objects-preloadable/issues))
data/README.md CHANGED
@@ -105,6 +105,28 @@ Preloading is lazy. The `redis_preload` scope attaches metadata to the relation,
105
105
 
106
106
  The type patches are applied via `prepend` on `Redis::Counter`, `Redis::Value`, `Redis::List`, `Redis::Set`, `Redis::SortedSet`, and `Redis::HashKey`.
107
107
 
108
+ ## Limitations
109
+
110
+ ### `record.reload` does not clear preloaded values
111
+
112
+ `reload` refreshes DB columns only. Preloaded Redis values remain cached on the redis-objects instances and are **not** updated.
113
+
114
+ ```ruby
115
+ widget = Widget.redis_preload(:view_count).first
116
+ widget.view_count.value # => 5 (preloaded)
117
+
118
+ # Another process increments the counter in Redis...
119
+
120
+ widget.reload
121
+ widget.view_count.value # => 5 (still the preloaded value — NOT refreshed)
122
+ ```
123
+
124
+ If you need a fresh Redis value after `reload`, fetch the record again without preloading:
125
+
126
+ ```ruby
127
+ Widget.find(widget.id).view_count.value # => hits Redis directly
128
+ ```
129
+
108
130
  ## Backward Compatibility: `read_redis_counter`
109
131
 
110
132
  If your models use the `read_redis_counter` helper (from the original Concern-based approach), it continues to work. With transparent preloading, you can remove explicit `read_redis_counter` calls and access `counter.value` directly.
@@ -34,6 +34,12 @@ class Redis
34
34
  @redis_preload_names || []
35
35
  end
36
36
 
37
+ # @api private
38
+ def reset
39
+ @redis_preload_context_attached = false
40
+ super
41
+ end
42
+
37
43
  # @api private
38
44
  def load
39
45
  result = super
@@ -3,7 +3,7 @@
3
3
  class Redis
4
4
  module Objects
5
5
  module Preloadable
6
- VERSION = "0.1.1"
6
+ VERSION = "0.1.2"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-objects-preloadable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyohah