store

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("key not found")

ErrNotFound is returned when a key is not found in the storage.

Functions

This section is empty.

Types

type MemoryPubSub

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

MemoryPubSub provides an in-memory implementation of the PubSub interface. It is intended for single-process environments where external infrastructure is not needed.

func NewMemoryPubSub

func NewMemoryPubSub() *MemoryPubSub

NewMemoryPubSub creates a new in-memory PubSub system.

func (*MemoryPubSub) Publish

func (p *MemoryPubSub) Publish(channel string, message []byte) error

Publish sends a message to all subscribers of a channel.

func (*MemoryPubSub) Subscribe

func (p *MemoryPubSub) Subscribe(channel string, handler func(message []byte)) error

Subscribe registers a handler function for messages on a channel.

type MemoryStorage

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

MemoryStorage provides an in-memory implementation of the Storage interface.

func NewMemoryStorage

func NewMemoryStorage() *MemoryStorage

NewMemoryStorage creates a new in-memory storage.

func (*MemoryStorage) Close added in v0.1.13

func (s *MemoryStorage) Close() error

Close explicitly stops the background pruning loop to prevent goroutine leaks.

func (*MemoryStorage) Delete

func (s *MemoryStorage) Delete(key string) error

Delete removes a value from the in-memory store.

func (*MemoryStorage) Get

func (s *MemoryStorage) Get(key string) ([]byte, error)

Get retrieves a value from the in-memory store.

func (*MemoryStorage) Set

func (s *MemoryStorage) Set(key string, val []byte, exp time.Duration) error

Set stores a value in the in-memory store.

type PubSub

type PubSub interface {
	Publish(channel string, message []byte) error
	Subscribe(channel string, handler func(message []byte)) error
}

PubSub represents an external publish-subscribe mechanism for multi-process broadcasting.

type Storage

type Storage interface {
	Get(key string) ([]byte, error)
	Set(key string, val []byte, exp time.Duration) error
	Delete(key string) error
}

Storage represents an external key-value store for session and state data.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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