Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a key_hash column to the solid_cache_entries table. This column is a 64-bit integer that is a truncated SHA256 hash of the key. This allows us to use a smaller index than the 1024 byte key column.
The byte_size column is also added to the table. This is the size of the value in bytes. This is for a separate feature but is included in this commit to piggy back on the migrations.
The migrations themselves are split into three steps. This allows existing tables to be migrated without downtime.
There is a new configuration field
key_hash_stage
that can be set to:ignored
,:unindexed
or:indexed
. This controls how the key_hash column is used and should be set as the migrations are completed.The default is :indexed, which is what is required for fresh installations of solid_cache. In this case you can apply all three migrations at the same time.
In the case of an existing setup however, the steps are:
config.solid_cache.key_hash_stage = :ignored
config.solid_cache.key_hash_stage = :unindexed
config.solid_cache.key_hash_stage = :indexed
For later versions of the gem we'll assume that the key_hash column exists and the
config.solid_cache.key_hash_stage
. We'll also squash the migrations into a single file.