storage

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseSecondaryStorage added in v1.3.0

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

DatabaseSecondaryStorage implements the SecondaryStorage interface using GORM.

func NewDatabaseSecondaryStorage added in v1.3.0

func NewDatabaseSecondaryStorage(db *gorm.DB, config *models.SecondaryStorageDatabaseOptions) *DatabaseSecondaryStorage

func (*DatabaseSecondaryStorage) Close added in v1.3.0

func (storage *DatabaseSecondaryStorage) Close() error

Close gracefully shuts down the storage by stopping the cleanup goroutine. This should be called when the application is shutting down.

func (*DatabaseSecondaryStorage) Delete added in v1.3.0

func (storage *DatabaseSecondaryStorage) Delete(ctx context.Context, key string) error

Delete removes a key from the database. Returns an error if the key does not exist.

func (*DatabaseSecondaryStorage) Get added in v1.3.0

func (storage *DatabaseSecondaryStorage) Get(ctx context.Context, key string) (any, error)

Get retrieves a value from the database by key. Returns an error if the key does not exist or has expired.

func (*DatabaseSecondaryStorage) Incr added in v1.3.0

func (storage *DatabaseSecondaryStorage) Incr(ctx context.Context, key string, ttl *time.Duration) (int, error)

Incr increments the integer value stored at key by 1. If the key does not exist, it is initialized to 0 and then incremented to 1. If ttl is provided, it will be set or updated on the key.

func (*DatabaseSecondaryStorage) Set added in v1.3.0

func (storage *DatabaseSecondaryStorage) Set(ctx context.Context, key string, value any, ttl *time.Duration) error

Set stores a value in the database with an optional TTL. The value must be a string. If ttl is nil, the entry will not expire.

type MemorySecondaryStorage added in v1.3.0

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

MemorySecondaryStorage is an in-memory implementation of SecondaryStorage.

func NewMemorySecondaryStorage added in v1.3.0

func NewMemorySecondaryStorage(config *models.SecondaryStorageMemoryOptions) *MemorySecondaryStorage

func (*MemorySecondaryStorage) Close added in v1.3.0

func (storage *MemorySecondaryStorage) Close() error

Close gracefully shuts down the storage by stopping the cleanup goroutine.

func (*MemorySecondaryStorage) Delete added in v1.3.0

func (storage *MemorySecondaryStorage) Delete(ctx context.Context, key string) error

Delete removes a key from storage. Returns an error if the key does not exist.

func (*MemorySecondaryStorage) Get added in v1.3.0

func (storage *MemorySecondaryStorage) Get(ctx context.Context, key string) (any, error)

Get retrieves a value from memory by key. Returns an error if the key does not exist or has expired.

func (*MemorySecondaryStorage) Incr added in v1.3.0

func (storage *MemorySecondaryStorage) Incr(ctx context.Context, key string, ttl *time.Duration) (int, error)

Incr increments the integer value stored at key by 1. If the key does not exist, it is initialized to 0 and then incremented to 1. If ttl is provided, it will be set or updated on the key.

func (*MemorySecondaryStorage) Set added in v1.3.0

func (storage *MemorySecondaryStorage) Set(ctx context.Context, key string, value any, ttl *time.Duration) error

Set stores a value in memory with an optional TTL. The value must be a string. If ttl is nil, the entry will not expire.

Jump to

Keyboard shortcuts

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