Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve serialization handling #217

Merged
merged 8 commits into from
Apr 9, 2023
Merged

Conversation

Turnerj
Copy link
Member

@Turnerj Turnerj commented Apr 7, 2023

Fixes #213 by disabling default behaviour in Protobuf but more than that, it prevents serialization exceptions from bubbling out. Instead they are caught (and now logged).

The result is, if there are serialization issues when setting the cache on a particular layer, besides the logging, that layer will be skipped and will cause a cache miss on that layer on future requests. When retrieving an item from the cache and that causes a serialization exception, this will just be treated as a cache miss on that layer.

Notes:

  • Cache Tower now takes a dependency on logging abstractions due to otherwise swallowing serialization exceptions. If you don't have logging configured, it will internally default to a NullLogger. It is using structured logging but only in these error paths - more complete structured logging changes are still to come.
  • Some obsolete methods with service collections have been removed (as it would have made adding the logging more complicated and messy anyway)
  • CacheEntry now has a parameter-less constructor and init-access (primarily to fix an issue that it was causing with Protobuf), however, this does mean you can set an expiry with greater than second precision. Some cache layers won't care but the MongoDB layer will not save any greater precision.

@Turnerj Turnerj force-pushed the improve-serialization-handling branch from 50d4415 to db2f191 Compare April 8, 2023 12:33
@Turnerj Turnerj merged commit 7b1910b into main Apr 9, 2023
@Turnerj Turnerj deleted the improve-serialization-handling branch April 9, 2023 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrading from v0.11.x to Custom Serializers with RedisCacheLayer breaks existing caches
1 participant