Skip to main content

Marshaler

No overview available.

Methods


Get()

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

Retrieves a value from the cache associated with the given key and unmarshals it into the provided return object. Callers use this to fetch cached data, which might involve I/O operations.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, allowing for cancellation and timeouts.
keyanyThe unique identifier for the cached item to retrieve.
returnObjanyThe object into which the retrieved cache value will be unmarshaled.

Returns

TypeDescription
any, errorThe unmarshaled object if successful, and an error if the retrieval or unmarshaling fails.

Set()

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

Stores an object in the cache under the specified key, marshaling the object before storage. Callers use this to persist data in the cache, which might involve I/O operations.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the operation, allowing for cancellation and timeouts.
keyanyThe unique identifier under which the object will be stored in the cache.
objectanyThe object to be marshaled and stored in the cache.
optionsstore.OptionOptional settings for the cache operation, such as expiration time.

Returns

TypeDescription
err errorAn error if the marshaling or storage operation fails, otherwise nil.