store_options.go
store_options.go - Overview
Defines options structures and functions for put and delete operations in the store.
Detailed Documentation
PutOptions
type PutOptions struct {
KeepTTL bool
PutCmd string
}
- Purpose: Defines options for put operations.
KeepTTL
: Whether to keep the existing TTL (Time To Live) of the key.PutCmd
: The command to use for the put operation.
getDefaultPutOptions
func getDefaultPutOptions() *PutOptions {
return &PutOptions{
KeepTTL: false,
PutCmd: Set,
}
}
- Purpose: Returns the default
PutOptions
. - Returns: A pointer to a
PutOptions
struct withKeepTTL
set tofalse
andPutCmd
set toSet
.
PutOption
type PutOption func(*PutOptions)
- Purpose: Defines a function type for setting
PutOptions
.
WithKeepTTL
func WithKeepTTL(value bool) PutOption {
return func(po *PutOptions) {
po.KeepTTL = value
}
}
- Purpose: Returns a
PutOption
that sets theKeepTTL
field of aPutOptions
struct. - Parameters:
value
: A boolean value to setKeepTTL
to.
- Returns: A
PutOption
function.
WithPutCmd
func WithPutCmd(cmd string) PutOption {
return func(po *PutOptions) {
po.PutCmd = cmd
}
}
- Purpose: Returns a
PutOption
that sets thePutCmd
field of aPutOptions
struct. - Parameters:
cmd
: A string value to setPutCmd
to.
- Returns: A
PutOption
function.
DelOptions
type DelOptions struct {
DelCmd string
}
- Purpose: Defines options for delete operations.
DelCmd
: The command to use for the delete operation.
getDefaultDelOptions
func getDefaultDelOptions() *DelOptions {
return &DelOptions{
DelCmd: Del,
}
}
- Purpose: Returns the default
DelOptions
. - Returns: A pointer to a
DelOptions
struct withDelCmd
set toDel
.
DelOption
type DelOption func(*DelOptions)
- Purpose: Defines a function type for setting
DelOptions
.
WithDelCmd
func WithDelCmd(cmd string) DelOption {
return func(po *DelOptions) {
po.DelCmd = cmd
}
}
- Purpose: Returns a
DelOption
that sets theDelCmd
field of aDelOptions
struct. - Parameters:
cmd
: A string value to setDelCmd
to.
- Returns: A
DelOption
function.