Check out solid_cache

This commit is contained in:
Andrew Tomaka 2024-09-08 21:36:31 -04:00
parent 80b12bfce8
commit f8677f8a78
Signed by: atomaka
GPG key ID: 61209BF70A5B18BE
6 changed files with 44 additions and 3 deletions

View file

@ -18,6 +18,7 @@ gem "jbuilder"
# Use Redis adapter to run Action Cable in production
# gem "redis", ">= 4.0.1"
gem "solid_cache"
gem "solid_queue"
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]

View file

@ -263,6 +263,10 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
solid_cache (1.0.5)
activejob (>= 7.2)
activerecord (>= 7.2)
railties (>= 7.2)
solid_queue (0.8.2)
activejob (>= 7.1)
activerecord (>= 7.1)
@ -325,6 +329,7 @@ DEPENDENCIES
rails!
rubocop-rails-omakase
selenium-webdriver
solid_cache
solid_queue
sqlite3 (>= 1.4)
stimulus-rails

View file

@ -21,5 +21,10 @@ test:
database: db/test.sqlite3
production:
primary:
<<: *default
database: db/production.sqlite3
database: storage/production.sqlite3
cache:
<<: *default
database: storage/production_cache.sqlite3
migrations_paths: db/cache_migrate

View file

@ -66,7 +66,7 @@ Rails.application.configure do
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
config.cache_store = :solid_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment).
config.active_job.queue_adapter = :solid_queue

16
config/solid_cache.yml Normal file
View file

@ -0,0 +1,16 @@
default: &default
database: cache
store_options:
# Cap age of oldest cache entry to fulfill retention policies
# max_age: <%= 60.days.to_i %>
max_size: <%= 256.megabytes %>
namespace: <%= Rails.env %>
development:
<<: *default
test:
<<: *default
production:
<<: *default

14
db/cache_schema.rb Normal file
View file

@ -0,0 +1,14 @@
# frozen_string_literal: true
ActiveRecord::Schema[7.1].define(version: 1) do
create_table "solid_cache_entries", force: :cascade do |t|
t.binary "key", limit: 1024, null: false
t.binary "value", limit: 536870912, null: false
t.datetime "created_at", null: false
t.integer "key_hash", limit: 8, null: false
t.integer "byte_size", limit: 4, null: false
t.index ["byte_size"], name: "index_solid_cache_entries_on_byte_size"
t.index ["key_hash", "byte_size"], name: "index_solid_cache_entries_on_key_hash_and_byte_size"
t.index ["key_hash"], name: "index_solid_cache_entries_on_key_hash", unique: true
end
end