Interface ICacheSerializer
Defines the contract for serialization of the cache value and cache items. The cache item serialization should be separated in case the serialization technology does not support immutable objects; in that case CacheItem<T> might not be serializable directly and the implementation has to wrap the cache item.
Namespace:CacheManager.Core.Internal
Assembly:CacheManager.Core.dll
Syntax
public interface ICacheSerializer
Methods
| Improve this Doc View SourceDeserialize(Byte[], Type)
Deserializes the data into the given target Type
.
Declaration
object Deserialize(byte[] data, Type target)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | data | The data which should be deserialized. |
Type | target | The type of the object to deserialize into. |
Returns
Type | Description |
---|---|
Object | The deserialized object. |
DeserializeCacheItem<T>(Byte[], Type)
Deserializes the value into a CacheItem<T>.
The valueType must not match the T in case
T is object
for example, the valueType
might be the real type of the value. This is needed to properly deserialize in some cases.
Declaration
CacheItem<T> DeserializeCacheItem<T>(byte[] value, Type valueType)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The data to deserialize from. |
Type | valueType | The type of the actual serialized cache value. |
Returns
Type | Description |
---|---|
CacheItem<T> | The deserialized cache item. |
Type Parameters
Name | Description |
---|---|
T | The type of the cache value. |
Serialize<T>(T)
Serializes the given value and returns the serialized data as byte array.
Declaration
byte[] Serialize<T>(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to serialize. |
Returns
Type | Description |
---|---|
System.Byte[] | The serialization result |
Type Parameters
Name | Description |
---|---|
T | The type of the value. |
SerializeCacheItem<T>(CacheItem<T>)
Serializes the given value.
Declaration
byte[] SerializeCacheItem<T>(CacheItem<T> value)
Parameters
Type | Name | Description |
---|---|---|
CacheItem<T> | value | The value to serialize. |
Returns
Type | Description |
---|---|
System.Byte[] | The serialized result. |
Type Parameters
Name | Description |
---|---|
T | The type of the cache value. |