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 ¶ 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
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.
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
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.