kasket 4.11.0 → 4.13.0

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: 724d92677bcdc757b647c3238bd34e53ea21bfc17887c59186cf4431c584eda3
4
- data.tar.gz: 38ff26970191ff1926d1e3d50e026d2d503398ef2b1bb884943b36e4e6bc4d37
3
+ metadata.gz: 0c1c83230c5c06c292c4dd62d839372d06a54a763ed7dfd0ea5ed339fb57913a
4
+ data.tar.gz: 96df87b7c7ee9f8f19e593b3bc3bcbad257d928e0cdc4e0b3f5b22afed00b9c6
5
5
  SHA512:
6
- metadata.gz: 6d32c14b1c040d6bca217235bb7c98c2f9a042a33a38b57ee3bc0acf4ac0695eb4b1d05039df354aef624f445a09fe93ef93fb0d29a3edfcf312c5ba957404be
7
- data.tar.gz: 506931cd595e66cccd2a6feeddeb2ff41dde52aba0fac6f5bd9e99f53b242eb5ef2626e1ff5f31c3d388594c4628e0d75fb86e7c76892e77625d441f19a393d7
6
+ metadata.gz: 1ced9df5e050870ed7446bcf1b2e469fa2954ce1e7afcd67b799b14bb25a7323690242ca5ebb097c8d7df7f5c0c70317a72f292c202bebcc189b7afb64e905d1
7
+ data.tar.gz: aef1d32b14c4d6c3526b2b9093fec72f2c1998c04bebcf40861a30a1226234e4a70976168e605358fb452ed9152e49a7d69564c2fd7583541056c66cbe7fc8f0
data/README.md CHANGED
@@ -137,6 +137,20 @@ Absolutely, but Cache Money does so much more.
137
137
  * The Cache Money code is overly complex.
138
138
  * Cache Money seems abandoned.
139
139
 
140
+ ## Development
141
+
142
+ Run the tests with:
143
+
144
+ ```
145
+ $ rake test
146
+ ```
147
+
148
+ Access a dev console running on the local test DB:
149
+
150
+ ```
151
+ $ bin/console
152
+ ```
153
+
140
154
  ## Note on Patches/Pull Requests
141
155
 
142
156
  * Fork the project.
@@ -8,14 +8,11 @@ module Kasket
8
8
  end
9
9
  end
10
10
 
11
- # *args can be replaced with (sql, *args) once we stop supporting Rails < 5.2
12
- def find_by_sql_with_kasket(*args)
13
- sql = args[0]
14
-
11
+ def find_by_sql_with_kasket(sql, binds = [], *restargs, **kwargs, &blk)
15
12
  if use_kasket?
16
13
  query = if sql.respond_to?(:to_kasket_query)
17
14
  if ActiveRecord::VERSION::STRING < '5.2'
18
- sql.to_kasket_query(self, args[1].map(&:value_for_database))
15
+ sql.to_kasket_query(self, binds.map(&:value_for_database))
19
16
  else
20
17
  sql.to_kasket_query(self)
21
18
  end
@@ -26,7 +23,7 @@ module Kasket
26
23
 
27
24
  if query && has_kasket_index_on?(query[:index])
28
25
  if query[:key].is_a?(Array)
29
- find_by_sql_with_kasket_on_id_array(query[:key])
26
+ filter_pending_records(find_by_sql_with_kasket_on_id_array(query[:key]), &blk)
30
27
  else
31
28
  if value = Kasket.cache.read(query[:key])
32
29
  # Identified a specific edge case where memcached server returns 0x00 binary protocol response with no data
@@ -37,11 +34,11 @@ module Kasket
37
34
  # The code in this first condition of TrueClass === true will
38
35
  # skip the kasket cache for these specific objects and go directly to SQL for retrieval.
39
36
  result_set = if value.is_a?(TrueClass)
40
- find_by_sql_without_kasket(*args)
37
+ find_by_sql_without_kasket(sql, binds, *restargs, **kwargs, &blk)
41
38
  elsif value.is_a?(Array)
42
39
  filter_pending_records(find_by_sql_with_kasket_on_id_array(value))
43
40
  else
44
- filter_pending_records(Array.wrap(value).collect { |record| instantiate(record.dup) })
41
+ filter_pending_records(Array.wrap(value).collect { |record| instantiate(record.dup, &blk) })
45
42
  end
46
43
 
47
44
  payload = {
@@ -51,19 +48,19 @@ module Kasket
51
48
 
52
49
  ActiveSupport::Notifications.instrument('instantiation.active_record', payload) { result_set }
53
50
  else
54
- store_in_kasket(query[:key], find_by_sql_without_kasket(*args))
51
+ store_in_kasket(query[:key], find_by_sql_without_kasket(sql, binds, *restargs, **kwargs, &blk))
55
52
  end
56
53
  end
57
54
  else
58
- find_by_sql_without_kasket(*args)
55
+ find_by_sql_without_kasket(sql, binds, *restargs, **kwargs, &blk)
59
56
  end
60
57
  end
61
58
 
62
- def find_by_sql_with_kasket_on_id_array(keys)
59
+ def find_by_sql_with_kasket_on_id_array(keys, &blk)
63
60
  key_attributes_map = Kasket.cache.read_multi(*keys)
64
61
 
65
62
  found_keys, missing_keys = keys.partition {|k| key_attributes_map[k] }
66
- found_keys.each {|k| key_attributes_map[k] = instantiate(key_attributes_map[k].dup) }
63
+ found_keys.each {|k| key_attributes_map[k] = instantiate(key_attributes_map[k].dup, &blk) }
67
64
  key_attributes_map.merge!(missing_records_from_db(missing_keys))
68
65
 
69
66
  key_attributes_map.values.compact
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Kasket
3
- VERSION = '4.11.0'
3
+ VERSION = '4.13.0'
4
4
  class Version
5
5
  MAJOR = Kasket::VERSION.split('.')[0]
6
6
  MINOR = Kasket::VERSION.split('.')[1]
@@ -8,14 +8,14 @@ module Kasket
8
8
  end
9
9
  end
10
10
 
11
- def update_counters_with_kasket_clearing(*args)
11
+ def update_counters_with_kasket_clearing(*args, **kwargs)
12
12
  remove_from_kasket(args[0])
13
- update_counters_without_kasket_clearing(*args)
13
+ update_counters_without_kasket_clearing(*args, **kwargs)
14
14
  end
15
15
 
16
- def transaction_with_kasket_disabled(*args)
16
+ def transaction_with_kasket_disabled(*args, **kwargs)
17
17
  without_kasket do
18
- transaction_without_kasket_disabled(*args) { yield }
18
+ transaction_without_kasket_disabled(*args, **kwargs) { yield }
19
19
  end
20
20
  end
21
21
  end
@@ -111,13 +111,13 @@ module Kasket
111
111
  Kasket.add_pending_record(self, _destroyed = true)
112
112
  end
113
113
 
114
- def committed!(*)
114
+ def committed!(*args, **kwargs)
115
115
  Kasket.clear_pending_records
116
116
  kasket_after_commit if persisted? || destroyed?
117
117
  super
118
118
  end
119
119
 
120
- def rolledback!(*)
120
+ def rolledback!(*args, **kwargs)
121
121
  Kasket.clear_pending_records
122
122
  super
123
123
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kasket
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.11.0
4
+ version: 4.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-06 00:00:00.000000000 Z
12
+ date: 2023-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord