Class RedbKeySerializer

Namespace: redb.Core.Utils
Assembly: redb.Core.dll

Serializes and deserializes Dictionary keys to/from _array_index (text) storage.
Simple keys (string, int, Guid, etc.) are serialized directly.
Complex keys (Tuple, custom classes) are serialized to Base64-encoded JSON.

public static class RedbKeySerializer

Inheritance

ObjectRedbKeySerializer

Methods

CanBeKey(Type)

Check if C# type is valid as Dictionary key

public static bool CanBeKey(Type keyType)

Deserialize<TKey>(string)

Deserialize _array_index text value to key

public static TKey Deserialize<TKey>(string arrayIndex)

DeserializeObject(string, Type)

Deserialize _array_index text value to key (non-generic version)

public static object? DeserializeObject(string arrayIndex, Type keyType)

GetKeyTypeId(Type)

Get RedbTypeIds constant for key type

public static long GetKeyTypeId(Type keyType)

IsComplexKey(Type)

Check if key type is a complex type requiring JSON serialization

public static bool IsComplexKey(Type keyType)

Serialize<TKey>(TKey)

Serialize key to _array_index text value

public static string Serialize<TKey>(TKey key)

SerializeObject(object, Type)

Serialize key to _array_index text value (non-generic version)

public static string SerializeObject(object key, Type keyType)