From 059d59e43770840830d8d610863da2f69f6547ca Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Thu, 19 Oct 2023 20:28:18 +0100 Subject: [PATCH] Set up Solid Cache --- Gemfile | 1 + Gemfile.lock | 3 +++ config/environments/production.rb | 2 +- ...9192600_create_solid_cache_entries.solid_cache.rb | 12 ++++++++++++ db/schema.rb | 9 ++++++++- 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20231019192600_create_solid_cache_entries.solid_cache.rb diff --git a/Gemfile b/Gemfile index 729f8cf..fcdfa41 100644 --- a/Gemfile +++ b/Gemfile @@ -15,6 +15,7 @@ gem "bcrypt", "~> 3.1.7" gem "bootsnap", require: false gem "kaminari" # Pagination +gem "solid_cache" group :development, :test do gem "debug", platforms: %i[ mri mingw x64_mingw ] diff --git a/Gemfile.lock b/Gemfile.lock index eb8b358..0772268 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -229,6 +229,8 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + solid_cache (0.1.0) + rails (>= 7) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -281,6 +283,7 @@ DEPENDENCIES puma rails (~> 7.1) selenium-webdriver + solid_cache sprockets-rails stimulus-rails turbo-rails diff --git a/config/environments/production.rb b/config/environments/production.rb index e3e3bb0..f1c95b3 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -56,7 +56,7 @@ Rails.application.configure do config.log_tags = [ :request_id ] # 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 = :resque diff --git a/db/migrate/20231019192600_create_solid_cache_entries.solid_cache.rb b/db/migrate/20231019192600_create_solid_cache_entries.solid_cache.rb new file mode 100644 index 0000000..4ff1fbd --- /dev/null +++ b/db/migrate/20231019192600_create_solid_cache_entries.solid_cache.rb @@ -0,0 +1,12 @@ +# This migration comes from solid_cache (originally 20230724121448) +class CreateSolidCacheEntries < ActiveRecord::Migration[7.0] + def change + create_table :solid_cache_entries do |t| + t.binary :key, null: false, limit: 1024 + t.binary :value, null: false, limit: 512.megabytes + t.datetime :created_at, null: false + + t.index :key, unique: true + end + end +end diff --git a/db/schema.rb b/db/schema.rb index eea9689..990a8c4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2023_10_19_172703) do +ActiveRecord::Schema[7.1].define(version: 2023_10_19_192600) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -77,6 +77,13 @@ ActiveRecord::Schema[7.1].define(version: 2023_10_19_172703) do t.index ["tag_id", "micropost_id"], name: "index_microposts_tags_on_tag_id_and_micropost_id" end + create_table "solid_cache_entries", force: :cascade do |t| + t.binary "key", null: false + t.binary "value", null: false + t.datetime "created_at", null: false + t.index ["key"], name: "index_solid_cache_entries_on_key", unique: true + end + create_table "tags", force: :cascade do |t| t.string "name", null: false t.datetime "created_at", null: false