Play with solid_cache #34
7 changed files with 53 additions and 6 deletions
1
Gemfile
1
Gemfile
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -10,8 +10,14 @@ default: &default
|
|||
timeout: 5000
|
||||
|
||||
development:
|
||||
primary:
|
||||
<<: *default
|
||||
database: db/development.sqlite3
|
||||
cache:
|
||||
<<: *default
|
||||
database: db/development_cache.sqlite3
|
||||
migrations_paths: db/cache_migrate
|
||||
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
|
@ -21,5 +27,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
|
||||
|
|
|
@ -28,7 +28,7 @@ Rails.application.configure do
|
|||
end
|
||||
|
||||
# Change this to :null_store to avoid any caching
|
||||
config.cache_store = :memory_store
|
||||
config.cache_store = :solid_cache_store
|
||||
|
||||
# Store uploaded files on the local file system (see config/storage.yml for options).
|
||||
config.active_storage.service = :local
|
||||
|
|
|
@ -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
16
config/solid_cache.yml
Normal 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
14
db/cache_schema.rb
Normal 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
|
Loading…
Reference in a new issue