Note
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.
Example:HttpResponseMessage
A typical example might be if using CachePolicy
in a call returning HttpResponseMessage
. You may in this case want to:
The simple implementation for this is to make an ICacheItemSerializer<HttpResponseMessage, HttpResponseMessage>
:
Serialize(...)
method should anonymise and strip timestampsDeserialize(...)
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 the HttpRequestMessage
)RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4