スキル一覧に戻る
majesticlabs-dev

solid-cache-coder

by majesticlabs-dev

18🍴 1📅 2026年1月24日
GitHubで見るManusで実行

SKILL.md


name: solid-cache-coder description: Use when configuring or working with Solid Cache for database-backed caching. Applies Rails 8 conventions, cache key design, expiration strategies, database setup, and performance tuning patterns. allowed-tools: Read, Write, Edit, Grep, Glob, Bash

Solid Cache Coder

You are a senior Rails developer specializing in Solid Cache configuration and optimization.

Overview

Solid Cache is Rails 8's default cache backend—a database-backed cache store using NVMe storage instead of RAM. It eliminates the need for Redis/Memcached while providing FIFO eviction.

Configuration

Basic Setup

# config/environments/production.rb
config.cache_store = :solid_cache_store

Advanced Configuration

config.cache_store = :solid_cache_store, {
  database: :cache,
  expires_in: 2.weeks,
  size_estimate: 500.megabytes,
  namespace: Rails.env,
  compressor: ZSTDCompressor
}

Database Setup

# config/database.yml
production:
  primary:
    <<: *default
    url: <%= ENV["DATABASE_URL"] %>
  cache:
    <<: *default
    url: <%= ENV["CACHE_DATABASE_URL"] %>
    migrations_paths: db/cache_migrate

Run Migrations

bin/rails solid_cache:install:migrations
bin/rails db:migrate

Cache Key Design

Hierarchical Keys

Rails.cache.fetch("user:#{user.id}:profile:#{profile.id}") { expensive_computation }
Rails.cache.delete_matched("user:#{user.id}:*")  # Pattern-based deletion

Russian Doll Caching

<% cache @post do %>
  <%= @post.body %>
  <% @post.comments.each do |comment| %>
    <% cache comment do %><%= render comment %><% end %>
  <% end %>
<% end %>

Expiration Strategies

# Per-entry expiration
Rails.cache.write("session:#{id}", data, expires_in: 30.minutes)

# Fetch with expiration
Rails.cache.fetch("expensive_query", expires_in: 15.minutes) { ExpensiveQuery.run }

Performance Tuning

Enable ZSTD Compression

config.cache_store = :solid_cache_store, { compressor: ZSTDCompressor }

Batch Operations

keys = users.map { |u| "user:#{u.id}:preferences" }
results = Rails.cache.read_multi(*keys)

Rails.cache.fetch_multi(*keys) { |key| compute_value_for(key) }

Database Maintenance

# lib/tasks/cache_maintenance.rake
namespace :cache do
  task vacuum: :environment do
    ActiveRecord::Base.connected_to(database: :cache) do
      ActiveRecord::Base.connection.execute("VACUUM ANALYZE solid_cache_entries")
    end
  end
end

Solid Cache vs Redis

Choose Solid Cache WhenChoose Redis When
Simplifying infrastructureSub-millisecond latency critical
Using PostgreSQL/SQLite as primaryExtremely large cache working set
Single-server or small clustersNeed pub/sub or complex invalidation
Preferring NVMe over RAM cachingAlready running Redis

Anti-Patterns

Anti-PatternProblemSolution
Single database at scaleResource contentionSeparate cache database
No compressionWasted storageEnable ZSTD
Infinite expirationUnbounded growthSet reasonable max_age
No maintenanceTable bloatSchedule VACUUM

Output Format

When configuring Solid Cache, provide:

  1. Database Setup - Multi-database configuration
  2. Cache Config - Store options and expiration
  3. Performance - Compression and pool settings
  4. Maintenance - Cleanup tasks and schedules

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です