IVitreousCacheSerializer interface
Namespace: Vitreous.Caching.Abstractions
Assembly: Vitreous.Caching.dll
Converts cached values to and from bytes. Used by both the IDistributedCache backend
and the Redis backend.
public interface IVitreousCacheSerializerRemarks
Section titled “Remarks”The default implementation is SystemTextJsonVitreousCacheSerializer.
Register your own implementation before calling AddVitreousCaching() or
AddVitreousRedisCaching() to replace it.
Implementations must make [TryDeserialize<T>](/Vitreous/api/vitreous/caching/abstractions/ivitreouscacheserializer/#Vitreous_Caching_Abstractions_IVitreousCacheSerializer_TryDeserialize__1_System_ReadOnlySpan_System_Byte____0__) return false
when the data was not written for T, so that two queries that
share a cache key but return different types can never read each other's entries.
Methods
Section titled “Methods”Serialize<T>(T)
Section titled “ Serialize<T>(T)”Serializes value, recording that it is a T.
byte[] Serialize<T>(T value)Parameters
Section titled “Parameters”value T
Returns
Section titled “Returns”byte[]
Type Parameters
Section titled “Type Parameters”T
TryDeserialize<T>(ReadOnlySpan<byte>, out T?)
Section titled “ TryDeserialize<T>(ReadOnlySpan<byte>, out T?)”Deserializes data as a T. Returns
false when the data holds a different type or an unrecognised format;
callers treat that as a cache miss.
bool TryDeserialize<T>(ReadOnlySpan<byte> data, out T? value)Parameters
Section titled “Parameters”data ReadOnlySpan<byte>
value T?
Returns
Section titled “Returns”Type Parameters
Section titled “Type Parameters”T