Documentation
¶
Index ¶
- type DatabaseSecondaryStorage
- func (storage *DatabaseSecondaryStorage) Close() error
- func (storage *DatabaseSecondaryStorage) Delete(ctx context.Context, key string) error
- func (storage *DatabaseSecondaryStorage) Get(ctx context.Context, key string) (any, error)
- func (storage *DatabaseSecondaryStorage) Incr(ctx context.Context, key string, ttl *time.Duration) (int, error)
- func (storage *DatabaseSecondaryStorage) Set(ctx context.Context, key string, value any, ttl *time.Duration) error
- type MemorySecondaryStorage
- func (storage *MemorySecondaryStorage) Close() error
- func (storage *MemorySecondaryStorage) Delete(ctx context.Context, key string) error
- func (storage *MemorySecondaryStorage) Get(ctx context.Context, key string) (any, error)
- func (storage *MemorySecondaryStorage) Incr(ctx context.Context, key string, ttl *time.Duration) (int, error)
- func (storage *MemorySecondaryStorage) Set(ctx context.Context, key string, value any, ttl *time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DatabaseSecondaryStorage ¶
type DatabaseSecondaryStorage struct {
// contains filtered or unexported fields
}
DatabaseSecondaryStorage implements the SecondaryStorage interface using GORM.
func NewDatabaseSecondaryStorage ¶
func NewDatabaseSecondaryStorage(db *gorm.DB, config *domain.SecondaryStorageDatabaseOptions) *DatabaseSecondaryStorage
func (*DatabaseSecondaryStorage) Close ¶
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 ¶
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 ¶
Get retrieves a value from the database by key. Returns an error if the key does not exist or has expired.
func (*DatabaseSecondaryStorage) Incr ¶
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.
type MemorySecondaryStorage ¶
type MemorySecondaryStorage struct {
// contains filtered or unexported fields
}
MemorySecondaryStorage is an in-memory implementation of SecondaryStorage.
func NewMemorySecondaryStorage ¶
func NewMemorySecondaryStorage(config *domain.SecondaryStorageMemoryOptions) *MemorySecondaryStorage
func (*MemorySecondaryStorage) Close ¶
func (storage *MemorySecondaryStorage) Close() error
Close gracefully shuts down the storage by stopping the cleanup goroutine.
func (*MemorySecondaryStorage) Delete ¶
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 ¶
Get retrieves a value from memory by key. Returns an error if the key does not exist or has expired.
func (*MemorySecondaryStorage) Incr ¶
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.