cache

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 1 Imported by: 19

Documentation

Overview

Package cache allows third parties to implement external storage for caching token data for distributed systems or multiple local applications access.

The data stored and extracted will represent the entire cache. Therefore it is recommended one msal instance per user. This data is considered opaque and there are no guarantees to implementers on the format being passed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExportHints added in v0.9.0

type ExportHints struct {
	// PartitionKey is a suggested key for partitioning the cache
	PartitionKey string
}

ExportHints are suggestions for storing data.

type ExportReplace

type ExportReplace interface {
	// Replace replaces the cache with what is in external storage. Implementors should honor
	// Context cancellations and return context.Canceled or context.DeadlineExceeded in those cases.
	Replace(ctx context.Context, cache Unmarshaler, hints ReplaceHints) error
	// Export writes the binary representation of the cache (cache.Marshal()) to external storage.
	// This is considered opaque. Context cancellations should be honored as in Replace.
	Export(ctx context.Context, cache Marshaler, hints ExportHints) error
}

ExportReplace exports and replaces in-memory cache data. It doesn't support nil Context or define the outcome of passing one. A Context without a timeout must receive a default timeout specified by the implementor. Retries must be implemented inside the implementation.

type Marshaler

type Marshaler interface {
	Marshal() ([]byte, error)
}

Marshaler marshals data from an internal cache to bytes that can be stored.

type ReplaceHints added in v0.9.0

type ReplaceHints struct {
	// PartitionKey is a suggested key for partitioning the cache
	PartitionKey string
}

ReplaceHints are suggestions for loading data.

type Serializer

type Serializer interface {
	Marshaler
	Unmarshaler
}

Serializer can serialize the cache to binary or from binary into the cache.

type Unmarshaler

type Unmarshaler interface {
	Unmarshal([]byte) error
}

Unmarshaler unmarshals data from a storage medium into the internal cache, overwriting it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL