Documentation
¶
Overview ¶
Package memory provides process-local authentication state storage.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
Options controls Store resource limits and time behavior. Zero values select conservative defaults.
type Store ¶
type Store[T any] struct { // contains filtered or unexported fields }
Store is a process-local authstate.Store intended for tests, development, and single-process deployments. Values are stored by assignment and must be treated as immutable by callers.
func NewStore ¶
NewStore constructs a bounded process-local authentication state store.
Example ¶
package main
import (
"context"
"fmt"
"time"
"github.com/shibukawa/popcornweb/authstate/memory"
)
func main() {
store, err := memory.NewStore[string](memory.Options{})
if err != nil {
panic(err)
}
expiresAt := time.Now().Add(time.Minute)
if err := store.Put(context.Background(), "login-state", "opaque-correlation", expiresAt); err != nil {
panic(err)
}
value, err := store.Take(context.Background(), "login-state")
if err != nil {
panic(err)
}
fmt.Println(value)
}
Output: opaque-correlation
Click to show internal directories.
Click to hide internal directories.