state

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStateTooLarge = errors.New("state data exceeds maximum size")
View Source
var ErrVersionMismatch = errors.New("state version mismatch")

Functions

This section is empty.

Types

type Encoding

type Encoding int
const (
	EncodingGob Encoding = iota
	EncodingJSON
)

type MapState

type MapState struct {
	// contains filtered or unexported fields
}

func NewMapState

func NewMapState() *MapState

func (*MapState) Delete

func (m *MapState) Delete(key string)

func (*MapState) Get

func (m *MapState) Get(key string) (interface{}, bool)

func (*MapState) Restore

func (m *MapState) Restore(data []byte) error

func (*MapState) Set

func (m *MapState) Set(key string, value interface{})

func (*MapState) Snapshot

func (m *MapState) Snapshot() ([]byte, error)

type Provider

type Provider interface {
	Snapshot() ([]byte, error)
	Restore([]byte) error
}

type Session

type Session struct {
	ID        string
	Data      map[string]interface{}
	CreatedAt time.Time
	ExpiresAt time.Time
}

type SessionStore

type SessionStore struct {
	// contains filtered or unexported fields
}

func NewSessionStore

func NewSessionStore() *SessionStore

func (*SessionStore) Cleanup

func (ss *SessionStore) Cleanup() int

func (*SessionStore) Count

func (ss *SessionStore) Count() int

func (*SessionStore) Create

func (ss *SessionStore) Create(id string, ttl time.Duration) *Session

func (*SessionStore) Delete

func (ss *SessionStore) Delete(id string)

func (*SessionStore) Get

func (ss *SessionStore) Get(id string) (*Session, bool)

func (*SessionStore) Restore

func (ss *SessionStore) Restore(data []byte) error

func (*SessionStore) Snapshot

func (ss *SessionStore) Snapshot() ([]byte, error)

type Store

type Store struct {
	// contains filtered or unexported fields
}

func NewStore

func NewStore() *Store

func (*Store) ProviderCount

func (s *Store) ProviderCount() int

func (*Store) Register

func (s *Store) Register(name string, provider Provider)

func (*Store) RegisterProvider

func (s *Store) RegisterProvider(provider Provider)

func (*Store) Restore

func (s *Store) Restore(data []byte) error

func (*Store) SetCompression

func (s *Store) SetCompression(enabled bool)

func (*Store) SetEncoding

func (s *Store) SetEncoding(enc Encoding)

func (*Store) Snapshot

func (s *Store) Snapshot() ([]byte, error)

func (*Store) Unregister

func (s *Store) Unregister(name string)

Jump to

Keyboard shortcuts

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