How huacnlee/rails-settings-cached works
Main Components Identification
The system consists of these primary components:
• Settings Model Layer
• Caching Layer
• Storage Layer
• Field Type System
• Rails Integration Layer
┌─────────────────────────────────────────┐
• RailsSettings::Base │
• (Core Settings Management Component) │
• ┘
┌─────────────────┐
• Field Types │
• ┤
• String │
• Integer │
• Boolean │
• Array │
• Hash │
• Float │
• BigDecimal │
• Custom Types │
• ┘
┌─────────────────┐
• Database Layer │
• (ActiveRecord)│
• ┘
┌─────────────────┐
• Cache Layer │
• (Rails.cache or │
• Custom Store) │
• ┘
┌─────────────────┐
• Rails App │
• Integration │
• ┘
Connection Flows
• Rails App → RailsSettings::Base (Setting access)
• RailsSettings::Base → Cache Layer (Check cache first)
• RailsSettings::Base → Database Layer (If cache miss)
• Field Types → RailsSettings::Base (Type conversion)
Important Elements
Request → Cache Check → Cache Hit → Return Value
• ↓
• Cache Miss
• ↓
• Database Query → Cache Update → Return Value
Field Configuration
• Key
• Type
• Default Value
• Validation Rules
• Readonly Flag
Additional Notes
• A note about the request-scoped caching using ActiveSupport::CurrentAttributes
• Validation flow for fields
• Configuration points (cache_prefix, cache_store)
• Readonly fields with a special indicator
Implementation Details
• The generator system for initial setup
• The middleware integration
• The railtie for Rails integration
• The configuration options
• The validation system