-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Anonymising and de timestamping cached data
ℹ️ This documentation describes the previous Polly v7 API. If you are using the new v8 API, please refer to pollydocs.org.
ICacheItemSerializer<TResult, TSerialized>
was introduced into Polly to allow CachePolicy
to serialize values to storage formats required by individual cache providers. However, serializers can also be used for manipulating data on the way in to and out of cache, without necessarily transforming the format.
This can be useful for anonymising content stored in the cache, and ensuring that content served from cache does not present incorrect timestamps if these aspects are important to you or if there is any danger of them leaking to the consumer.
A typical example might be if using CachePolicy
in a call returning HttpResponseMessage
. You may in this case want to:
- anonymize before caching: remove any header information you consider personal to or varying with the original requester (eg Cookie; User-Agent and others);
- re-personalize (re-create corresponding headers relevant to the later requester) after retrieving the anonymised version from cache.
- de-timestamp: remove timestamps before storing in the cache;
- re-timestamp with current time when returning items from cache
The simple implementation for this is to make an ICacheItemSerializer<HttpResponseMessage, HttpResponseMessage>
:
- the
Serialize(...)
method should anonymise and strip timestamps - the
Deserialize(...)
method should re-timestamp and re-personalize where possible (some re-personalisation may have to remain with calling code, which has access to further personal context from theHttpRequestMessage
)
- Home
- Polly RoadMap
- Contributing
- Transient fault handling and proactive resilience engineering
- Supported targets
- Retry
- Circuit Breaker
- Advanced Circuit Breaker
- Timeout
- Bulkhead
- Cache
- Rate-Limit
- Fallback
- PolicyWrap
- NoOp
- PolicyRegistry
- Polly and HttpClientFactory
- Asynchronous action execution
- Handling InnerExceptions and AggregateExceptions
- Statefulness of policies
- Keys and Context Data
- Non generic and generic policies
- Polly and interfaces
- Some policy patterns
- Debugging with Polly in Visual Studio
- Unit-testing with Polly
- Polly concept and architecture
- Polly v6 breaking changes
- Polly v7 breaking changes
- DISCUSSION PROPOSAL- Polly eventing and metrics architecture