Replaced CachedAt and TimeToLive fields with single Expiry field #13
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.
The primary goal is to save allocations and serializer costs of storing two fields (16 bytes total) instead of a single field (8 bytes total). While these values are very small, being part of the
CacheEntry
type meant they were propagated everywhere and serializers needed to handle these values even if they rarely (if ever) dealt with anything but the expiry.Rather than try and complicate the code by switching what type is being used where, it would instead do a slight change to make parts that needed
CachedAt
(primarily around dealing with the stale date) reverse calculate it from the expiry andCacheSettings.TimeToLive
value. Even with that in mind, it shows a net improvement in allocations (though small) and even subtle improvements to performance.