Rails 5.2 standardizes credentials and cache behavior
Rails 5.2 ships encrypted credentials, Active Storage and a Redis cache store. Their implementations make different commitments about keys, persistence and failures that application operators need to understand.
A framework default is an operational decision once an application depends on it. Rails 5.2 adds encrypted credentials and a Redis cache store alongside Active Storage. Each reduces application-specific integration work, but each also has a different relationship with the resources outside the application process.
The April 9 final release announcement presents these additions as standard framework components. Credentials centralize encrypted application secrets. The Redis store supplies Rails caching behavior, including the decision to turn connection failures into misses for ordinary fetches. Active Storage provides file attachments backed by storage services.
The useful question is what each component requires when its normal path fails. An encrypted configuration needs its decryption key. A cache may deliberately permit the application to continue without a stored value. An attachment's metadata can exist separately from its bytes. These contracts affect how the convenience behaves in a running system.
I find Ruby's consistency useful when a common abstraction has a clear job. Rails adds another layer of conventions on that language model. The new components are easiest to reason about when their external dependencies remain explicit, even though the framework supplies the implementation.
Credentials separate ciphertext from access to it
Rails.application.credentials uses config/credentials.yml.enc in the 5.2 application implementation. The default encryption key comes from config/master.key or the RAILS_MASTER_KEY environment variable. The encrypted file and the means of reading it therefore have separate distribution requirements.
The announcement's revision-control claim depends on that separation. The encrypted credentials can accompany application source while the key stays outside revision control. Storing both together would defeat the intended access distinction. Encryption does not remove the need to decide who receives the key.
This arrangement allows an application revision to carry the encrypted configuration it expects. A deployment still needs the corresponding key before it can read the values. The framework supplies a common file format and access path, while the operator supplies that separate authority.
The application helper also exposes encrypted configuration beyond the default credentials file. It accepts custom paths and key sources. That broader API lets an application use the same mechanism for another encrypted configuration without treating every such file as the default credentials document.
Editing includes a temporary plaintext representation
The credentials command loads the application environment and checks for an editor. If no key exists, its edit path creates a master-key file and arranges for that file to be ignored by version control. It also creates credentials content when needed.
The documented command is straightforward.
bin/rails credentials:edit
Underneath it, ActiveSupport::EncryptedFile decrypts the content into a temporary file for editing. After the editor returns, it reads the result, rewrites encrypted content if it changed and removes the temporary file in an ensure block.
This is an important qualification to the phrase always encrypted. The persisted credentials artifact is encrypted, while authorized use necessarily produces plaintext. The editor receives that plaintext through a temporary path. Runtime reads likewise need decryption before application code can consume a credential.
The encrypted-file implementation uses AES-128-GCM through ActiveSupport::MessageEncryptor. Its read path calls decryption and verification, while its write path encrypts and signs before replacing the encrypted file. The source shows a temporary encrypted output followed by a move to the content path.
Key lookup prefers the environment value to the key file. Missing-key behavior depends on the configured requirement, which the application helper passes through from config.require_master_key. These are specific framework choices that explain how a deployment obtains the configuration and how a missing prerequisite becomes visible.
The benefit is a standard workflow for the encrypted artifact. It does not mean that a key can be omitted from deployment planning or that a process holding the key lacks access to plaintext. The implementation defines exactly where that access occurs.
The Redis cache treats connection loss as an expected failure
The 5.2 RedisCacheStore source documents ordinary cache fetches as misses and writes as dropped when the server is unavailable. Its failsafe helper catches Redis connection errors, invokes an error handler and returns the operation's fallback.
That behavior permits the application to compute a value when the cache cannot supply it. The cache is an optimization whose absence should be survivable for those operations. This is a different contract from the credentials file, whose unreadable content cannot simply be replaced by a cache miss.
The implementation's exception handling is also more specific than swallowing every possible failure. The failsafe helper rescues Redis's base connection error type. Programming errors and unrelated exceptions are not automatically covered by that clause. Understanding the class of failure matters when interpreting the announcement's fault-tolerance description.
Some administrative behavior has its own path. For example, delete_matched operates through a Redis glob and a Lua script and is documented as raising errors. A broad statement that every Redis-related failure becomes a miss would therefore be inaccurate.
My preference is for cache behavior to make the durability assumption visible. A cache that can drop writes is appropriate only when the underlying value can be recovered or recomputed elsewhere. The API's convenience does not make it a substitute for the application's authoritative storage.
Cache memory policy remains an external dependency
The store does not set an expiration on entries by default. Its source expects Redis to have an eviction policy that removes entries when configured memory fills. The deployment note recommends a dedicated Redis cache because mixed usage patterns do not fit that assumption well.
This matters when a Redis instance also contains data with another lifetime contract. Cache eviction and persistent application state need different policies. A namespace distinguishes keys, but it does not by itself provide an independent memory-management policy for each kind of data.
Compression is enabled by default for values above a one-kilobyte threshold. The store supports changing that threshold or disabling compression. It also limits long keys by retaining a prefix and appending a SHA2 digest. These implementation choices affect the representation sent to Redis while preserving a common Rails cache API.
The store supports Redis::Distributed for sharding, and the announcement highlights distributed multi-get for collection caching. That is useful because rendering several cached fragments can need several values at once. The implementation checks its client capabilities and chooses multi-value operations accordingly.
The announcement also describes key recycling as a way to improve cache efficiency. Its reported cache-lifetime improvements come from Basecamp's use and should not be treated as a prediction for every application. The mechanism and deployment policy are more transferable than that particular observed result.
Attachments have a different persistence contract
Active Storage's release-candidate documentation, already public before the final release, explains the distinction between Blob and Attachment records. Blob describes a file and its storage-service key. Attachment joins that blob to an application record. The actual bytes remain in the storage service.
That means an attachment is not equivalent to an ordinary cache entry. Losing the storage object can lose application content, even while the associated database metadata remains. The framework's common API does not make that object recomputable in the way a cached fragment may be.
The final announcement includes direct cloud uploads, on-demand image variants and previews for videos or PDFs. Metadata analysis can happen asynchronously. These operations provide standard handling for files, but they still depend on storage and processing resources beyond the model row.
The documented purge operations make the resource boundary explicit. Synchronous purge destroys associated records and files, while purge_later delegates the work through Active Job. Application behavior around attachment deletion therefore includes database state, object storage and potentially a job queue.
The final release supplies shared implementations
Rails 5.2 also includes a Content Security Policy configuration DSL and Early Hints support, and adds Bootsnap to the default Gemfile. The release announcement describes a framework continuing to incorporate common application concerns. Those additions have their own requirements rather than one universal operational model.
The credentials and cache implementations illustrate the distinction. A credential read requires a key capable of decrypting its content. A cache fetch can recover from a connection failure by behaving as a miss. An attachment associates database metadata with stored content whose continued existence matters to the application.
These defaults reduce the amount of custom code needed to establish those relationships. The remaining application work is to supply the resources each component assumes, including the separate credentials key, an appropriate cache memory policy and the storage service holding attachment bytes.