Skip to main content

TypedMarshaler

This class handles typed marshaling and unmarshaling operations. It encapsulates a Marshaler and stores information about whether the type is a pointer and its element type for efficient processing.

Methods


Set()

@classmethod
def Set(
ctx: context.Context,
key: any,
object: T,
options: store.Option
) - > error

Stores an object in the underlying store with a given key. This method marshals the object before storing it.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, allowing for cancellation and deadlines.
keyanyThe key used to identify the object in the store.
objectTThe object to be stored, which will be marshaled according to the TypedMarshaler's configuration.
optionsstore.OptionOptional settings for the store operation, such as expiration or conditional writes.

Returns

TypeDescription
errorAn error if the operation fails, otherwise nil.

Get()

@classmethod
def Get(
ctx: context.Context,
key: any
) - > (T, error)

Retrieves an object from the underlying store using a given key. This method unmarshals the retrieved data into the specified type T.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, allowing for cancellation and deadlines.
keyanyThe key used to identify the object in the store.

Returns

TypeDescription
(T, error)The unmarshaled object of type T and an error if the operation fails or the key is not found.