Skip to main content

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 with KeepTTL set to false and PutCmd set to Set.

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 the KeepTTL field of a PutOptions struct.
  • Parameters:
    • value: A boolean value to set KeepTTL to.
  • Returns: A PutOption function.

WithPutCmd

func WithPutCmd(cmd string) PutOption {
return func(po *PutOptions) {
po.PutCmd = cmd
}
}
  • Purpose: Returns a PutOption that sets the PutCmd field of a PutOptions struct.
  • Parameters:
    • cmd: A string value to set PutCmd 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 with DelCmd set to Del.

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 the DelCmd field of a DelOptions struct.
  • Parameters:
    • cmd: A string value to set DelCmd to.
  • Returns: A DelOption function.

Getting Started Relevance