Skip to content

Commit 84bd8fa

Browse files
committed
Merge branch 'main' into generate-cache-file-ready-for-development-env-too
2 parents ca1327d + bda73a2 commit 84bd8fa

35 files changed

+2643
-119
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ jobs:
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
ruby-version: ["3.1", "3.2", "3.3"]
31-
gemfile: [ rails_7_2, rails_8_0, rails_main ]
30+
ruby-version: ["3.1", "3.2", "3.3", "3.4"]
31+
gemfile: [ rails_7_2, rails_8_0, rails_8_1, rails_main ]
3232
database: [sqlite, postgres, mysql]
3333
exclude:
3434
- ruby-version: "3.1"
3535
gemfile: rails_8_0
36+
- ruby-version: "3.1"
37+
gemfile: rails_8_1
3638
- ruby-version: "3.1"
3739
gemfile: rails_main
3840
services:

Appraisals

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ appraise "rails-7-2" do
44
gem "railties", github: "rails/rails", branch: "7-2-stable"
55
end
66

7+
appraise "rails-8-0" do
8+
gem "railties", github: "rails/rails", branch: "8-0-stable"
9+
end
10+
11+
appraise "rails-8-1" do
12+
gem "railties", github: "rails/rails", branch: "8-1-stable"
13+
end
14+
715
appraise "rails-main" do
816
gem "railties", github: "rails/rails", branch: "main"
917
end

Gemfile.lock

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
PATH
22
remote: .
33
specs:
4-
solid_cache (1.0.7)
4+
solid_cache (1.0.8)
55
activejob (>= 7.2)
66
activerecord (>= 7.2)
77
railties (>= 7.2)
88

99
GEM
1010
remote: https://rubygems.org/
1111
specs:
12-
actionpack (7.2.2.1)
13-
actionview (= 7.2.2.1)
14-
activesupport (= 7.2.2.1)
12+
actionpack (7.2.2.2)
13+
actionview (= 7.2.2.2)
14+
activesupport (= 7.2.2.2)
1515
nokogiri (>= 1.8.5)
1616
racc
1717
rack (>= 2.2.4, < 3.2)
@@ -20,22 +20,22 @@ GEM
2020
rails-dom-testing (~> 2.2)
2121
rails-html-sanitizer (~> 1.6)
2222
useragent (~> 0.16)
23-
actionview (7.2.2.1)
24-
activesupport (= 7.2.2.1)
23+
actionview (7.2.2.2)
24+
activesupport (= 7.2.2.2)
2525
builder (~> 3.1)
2626
erubi (~> 1.11)
2727
rails-dom-testing (~> 2.2)
2828
rails-html-sanitizer (~> 1.6)
29-
activejob (7.2.2.1)
30-
activesupport (= 7.2.2.1)
29+
activejob (7.2.2.2)
30+
activesupport (= 7.2.2.2)
3131
globalid (>= 0.3.6)
32-
activemodel (7.2.2.1)
33-
activesupport (= 7.2.2.1)
34-
activerecord (7.2.2.1)
35-
activemodel (= 7.2.2.1)
36-
activesupport (= 7.2.2.1)
32+
activemodel (7.2.2.2)
33+
activesupport (= 7.2.2.2)
34+
activerecord (7.2.2.2)
35+
activemodel (= 7.2.2.2)
36+
activesupport (= 7.2.2.2)
3737
timeout (>= 0.4.0)
38-
activesupport (7.2.2.1)
38+
activesupport (7.2.2.2)
3939
base64
4040
benchmark (>= 0.3)
4141
bigdecimal
@@ -52,43 +52,43 @@ GEM
5252
rake
5353
thor (>= 0.14.0)
5454
ast (2.4.2)
55-
base64 (0.2.0)
56-
benchmark (0.4.0)
57-
bigdecimal (3.1.8)
55+
base64 (0.3.0)
56+
benchmark (0.4.1)
57+
bigdecimal (3.2.2)
5858
builder (3.3.0)
59-
concurrent-ruby (1.3.4)
60-
connection_pool (2.4.1)
59+
concurrent-ruby (1.3.5)
60+
connection_pool (2.5.3)
6161
crass (1.0.6)
6262
date (3.4.1)
6363
debug (1.9.1)
6464
irb (~> 1.10)
6565
reline (>= 0.3.8)
66-
drb (2.2.1)
66+
drb (2.2.3)
6767
erubi (1.13.0)
6868
globalid (1.2.1)
6969
activesupport (>= 6.1)
70-
i18n (1.14.6)
70+
i18n (1.14.7)
7171
concurrent-ruby (~> 1.0)
7272
io-console (0.8.0)
7373
irb (1.14.1)
7474
rdoc (>= 4.0.0)
7575
reline (>= 0.4.2)
7676
json (2.9.0)
7777
language_server-protocol (3.17.0.3)
78-
logger (1.6.2)
78+
logger (1.7.0)
7979
loofah (2.23.1)
8080
crass (~> 1.0.2)
8181
nokogiri (>= 1.12.0)
82-
minitest (5.25.4)
82+
minitest (5.25.5)
8383
mocha (2.1.0)
8484
ruby2_keywords (>= 0.0.5)
8585
msgpack (1.7.2)
8686
mysql2 (0.5.5)
87-
nokogiri (1.18.8-arm64-darwin)
87+
nokogiri (1.18.9-arm64-darwin)
8888
racc (~> 1.4)
89-
nokogiri (1.18.8-x86_64-darwin)
89+
nokogiri (1.18.9-x86_64-darwin)
9090
racc (~> 1.4)
91-
nokogiri (1.18.8-x86_64-linux-gnu)
91+
nokogiri (1.18.9-x86_64-linux-gnu)
9292
racc (~> 1.4)
9393
parallel (1.26.3)
9494
parser (3.3.6.0)
@@ -99,7 +99,7 @@ GEM
9999
date
100100
stringio
101101
racc (1.8.1)
102-
rack (3.1.16)
102+
rack (3.1.18)
103103
rack-session (2.1.1)
104104
base64 (>= 0.1.0)
105105
rack (>= 3.0.0)
@@ -114,9 +114,9 @@ GEM
114114
rails-html-sanitizer (1.6.1)
115115
loofah (~> 2.21)
116116
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
117-
railties (7.2.2.1)
118-
actionpack (= 7.2.2.1)
119-
activesupport (= 7.2.2.1)
117+
railties (7.2.2.2)
118+
actionpack (= 7.2.2.2)
119+
activesupport (= 7.2.2.2)
120120
irb (~> 1.13)
121121
rackup (>= 1.0.0)
122122
rake (>= 12.2)
@@ -158,20 +158,20 @@ GEM
158158
rubocop-ast (>= 1.30.0, < 2.0)
159159
ruby-progressbar (1.13.0)
160160
ruby2_keywords (0.0.5)
161-
securerandom (0.4.0)
161+
securerandom (0.4.1)
162162
sprockets (4.2.1)
163163
concurrent-ruby (~> 1.0)
164164
rack (>= 2.2.4, < 4)
165165
sprockets-rails (3.4.2)
166166
actionpack (>= 5.2)
167167
activesupport (>= 5.2)
168168
sprockets (>= 3.0.0)
169-
sqlite3 (2.7.3-arm64-darwin)
170-
sqlite3 (2.7.3-x86_64-darwin)
171-
sqlite3 (2.7.3-x86_64-linux-gnu)
169+
sqlite3 (2.7.4-arm64-darwin)
170+
sqlite3 (2.7.4-x86_64-darwin)
171+
sqlite3 (2.7.4-x86_64-linux-gnu)
172172
stringio (3.1.2)
173173
thor (1.3.2)
174-
timeout (0.4.2)
174+
timeout (0.4.3)
175175
tzinfo (2.0.6)
176176
concurrent-ruby (~> 1.0)
177177
unicode-display_width (3.1.2)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ production: &production
6464
databases: [production_cache1, production_cache2]
6565
store_options:
6666
<<: *default_store_options
67-
max_entries: <%= 256.gigabytes %>
67+
max_size: <%= 256.gigabytes %>
6868
```
6969

7070
For the full list of keys for `store_options` see [Cache configuration](#cache-configuration). Any options passed to the cache lookup will overwrite those specified here.

app/models/solid_cache/entry.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ def read_multi(keys)
4141
keys.each_slice(MULTI_BATCH_SIZE).each do |keys_batch|
4242
query = Arel.sql(select_sql(keys_batch), *key_hashes_for(keys_batch))
4343

44-
results.merge!(connection.select_all(query, "SolidCache::Entry Load").cast_values(attribute_types).to_h)
44+
with_connection do |connection|
45+
results.merge!(connection.select_all(query, "SolidCache::Entry Load").cast_values(attribute_types).to_h)
46+
end
4547
end
4648
end
4749
end
@@ -54,7 +56,9 @@ def delete_by_key(*keys)
5456
end
5557

5658
def clear_truncate
57-
connection.truncate(table_name)
59+
with_connection do |connection|
60+
connection.truncate(table_name)
61+
end
5862
end
5963

6064
def clear_delete
@@ -91,7 +95,9 @@ def add_key_hash_and_byte_size(payloads)
9195
end
9296

9397
def upsert_unique_by
94-
connection.supports_insert_conflict_target? ? :key_hash : nil
98+
with_connection do |connection|
99+
connection.supports_insert_conflict_target? ? :key_hash : nil
100+
end
95101
end
96102

97103
# This constructs and caches a SQL query for a given number of keys.

app/models/solid_cache/record.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@ def disable_instrumentation(&block)
1414
end
1515

1616
def with_instrumenter(instrumenter, &block)
17-
if connection.respond_to?(:with_instrumenter)
18-
connection.with_instrumenter(instrumenter, &block)
19-
else
20-
begin
21-
old_instrumenter, ActiveSupport::IsolatedExecutionState[:active_record_instrumenter] = ActiveSupport::IsolatedExecutionState[:active_record_instrumenter], instrumenter
22-
block.call
23-
ensure
24-
ActiveSupport::IsolatedExecutionState[:active_record_instrumenter] = old_instrumenter
17+
with_connection do |connection|
18+
if connection.respond_to?(:with_instrumenter)
19+
connection.with_instrumenter(instrumenter, &block)
20+
else
21+
begin
22+
old_instrumenter, ActiveSupport::IsolatedExecutionState[:active_record_instrumenter] = ActiveSupport::IsolatedExecutionState[:active_record_instrumenter], instrumenter
23+
block.call
24+
ensure
25+
ActiveSupport::IsolatedExecutionState[:active_record_instrumenter] = old_instrumenter
26+
end
2527
end
2628
end
2729
end

gemfiles/rails_8_1.gemfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "sqlite3"
6+
gem "mysql2"
7+
gem "pg"
8+
gem "sprockets-rails"
9+
gem "appraisal"
10+
gem "railties", branch: "8-1-stable", git: "https://github.com/rails/rails.git"
11+
12+
group :rubocop do
13+
gem "rubocop", ">= 1.25.1", require: false
14+
gem "rubocop-minitest", require: false
15+
gem "rubocop-packaging", require: false
16+
gem "rubocop-performance", require: false
17+
gem "rubocop-rails", require: false
18+
gem "rubocop-md", require: false
19+
end
20+
21+
gemspec path: "../"

lib/solid_cache/configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def set_connects_to(database:, databases:, connects_to:)
3737
when database
3838
{ shards: { database.to_sym => { writing: database.to_sym } } }
3939
when databases
40-
{ shards: databases.map(&:to_sym).index_with { |database| { writing: database } } }
40+
{ shards: Array(databases).map(&:to_sym).index_with { |database| { writing: database } } }
4141
when connects_to
4242
connects_to
4343
else

lib/solid_cache/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Engine < ::Rails::Engine
4141
end
4242

4343
config.after_initialize do
44-
if SolidCache.configuration.encrypt? && Record.connection.adapter_name == "PostgreSQL" && Rails::VERSION::MAJOR <= 7
44+
if SolidCache.configuration.encrypt? && Record.lease_connection.adapter_name == "PostgreSQL" && Rails::VERSION::MAJOR <= 7
4545
raise \
4646
"Cannot enable encryption for Solid Cache: in Rails 7, Active Record Encryption does not support " \
4747
"encrypting binary columns on PostgreSQL"

lib/solid_cache/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module SolidCache
4-
VERSION = "1.0.7"
4+
VERSION = "1.0.8"
55
end

0 commit comments

Comments
 (0)