Documentation
¶
Index ¶
- type Interface
- type Kv
- func (kv *Kv) Del(ctx context.Context, key string) error
- func (kv *Kv) Exists(ctx context.Context, key string) (bool, error)
- func (kv *Kv) Get(ctx context.Context, key string) (*KvItem, error)
- func (kv *Kv) SetWithExpireAt(ctx context.Context, key, value string, expireAt time.Time) error
- func (kv *Kv) SetWithTTL(ctx context.Context, key, value string, ttl time.Duration) error
- type KvItem
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface { SetWithTTL(ctx context.Context, key, value string, ttl time.Duration) error SetWithExpireAt(ctx context.Context, key, value string, expireAt time.Time) error Get(ctx context.Context, key string) (*KvItem, error) Exists(ctx context.Context, key string) (bool, error) Del(ctx context.Context, key string) error }
Interface is a kv interface
type Kv ¶
type Kv struct {
// contains filtered or unexported fields
}
Kv is a key-value store for postgres
func (*Kv) Get ¶
Get retrieves the key's document. If the key is expired, it deletes the record and returns an error.
func (*Kv) SetWithExpireAt ¶
SetWithExpireAt stores the key-value pair with a specific expiration time. Uses GORM's OnConflict clause to avoid SQL injection risks.
Click to show internal directories.
Click to hide internal directories.