Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rromanchuk committed Nov 25, 2024
1 parent d07fa27 commit b4519d5
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 13 deletions.
2 changes: 2 additions & 0 deletions personal/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,5 @@ gem 'marginalia'
gem 'ox', require: false

gem "solid_cache", "~> 1.0"

gem "sqlite3", "~> 2.3"
5 changes: 5 additions & 0 deletions personal/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ GEM
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sqlite3 (2.3.0)
mini_portile2 (~> 2.8.0)
sqlite3 (2.3.0-aarch64-linux-gnu)
sqlite3 (2.3.0-arm64-darwin)
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.2)
Expand Down Expand Up @@ -553,6 +557,7 @@ DEPENDENCIES
sitemap_generator
solid_cache (~> 1.0)
sprockets-rails
sqlite3 (~> 2.3)
stimulus-rails
turbo-rails
tzinfo-data
Expand Down
17 changes: 17 additions & 0 deletions personal/config/cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
default: &default
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:
database: cache
<<: *default

test:
<<: *default

production:
database: cache
<<: *default
8 changes: 8 additions & 0 deletions personal/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ development:
database: ro_development
host: localhost
migrations_paths: db/ro
cache:
adapter: sqlite3
database: storage/development_cache.sqlite3
migrations_paths: db/cache

test:
primary:
Expand Down Expand Up @@ -84,3 +88,7 @@ production:
password: <%= ENV["DATABASE_PASSWORD"] %>
host: <%= ENV['DATABASE_HOST'] %>
migrations_paths: db/ro
cache:
adapter: sqlite3
database: storage/production_cache.sqlite3
migrations_paths: db/cache
23 changes: 12 additions & 11 deletions personal/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,21 @@
if Rails.root.join('tmp/caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :solid_cache_store

config.cache_store = :redis_cache_store, { url: "redis://localhost:6379/0",
# config.cache_store = :redis_cache_store, { url: "redis://localhost:6379/0",

connect_timeout: 30, # Defaults to 20 seconds
read_timeout: 0.2, # Defaults to 1 second
write_timeout: 0.2, # Defaults to 1 second
reconnect_attempts: 1, # Defaults to 0
expires_in: 3.months,
error_handler: -> (method:, returning:, exception:) {
# connect_timeout: 30, # Defaults to 20 seconds
# read_timeout: 0.2, # Defaults to 1 second
# write_timeout: 0.2, # Defaults to 1 second
# reconnect_attempts: 1, # Defaults to 0
# expires_in: 3.months,
# error_handler: -> (method:, returning:, exception:) {

Sentry.capture_exception exception, level: 'warning',
tags: { method: method, returning: returning }
}
}
# Sentry.capture_exception exception, level: 'warning',
# tags: { method: method, returning: returning }
# }
# }
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
Expand Down
3 changes: 1 addition & 2 deletions personal/config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@
config.log_tags = [:request_id]

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
config.cache_store = :redis_cache_store, { url: 'redis://localhost:6379/0', expires_in: 1.day }
config.cache_store = :solid_cache_store


# Use a real queuing backend for Active Job (and separate queues per environment).
Expand Down
14 changes: 14 additions & 0 deletions personal/db/cache/20241124234620_solid_cache_init.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class SolidCacheInit < ActiveRecord::Migration[7.2]
def change
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
end
24 changes: 24 additions & 0 deletions personal/db/cache_schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.2].define(version: 2024_11_24_234620) 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

0 comments on commit b4519d5

Please sign in to comment.