godis

package
v0.0.0-...-e1299a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeAck = "ACK"
	TypeNil = "NIL"
	TypeStr = "STR"
	TypeInt = "INT"
	TypeArr = "ARR"
	TypeErr = "ERR"
)
View Source
const (
	ErrUnknownCmd = "unknown command"
	ErrWrongArgs  = "wrong number of arguments for command"
	ErrWrongType  = "WRONGTYPE operation against a key holding the wrong kind of value"
)

Variables

This section is empty.

Functions

func SaveStore

func SaveStore(store *StandardStore, writer io.Writer) error

func SaveStoreToFile

func SaveStoreToFile(store *StandardStore, name string) error

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(addr string) *Client

func (*Client) Dial

func (c *Client) Dial() error

func (*Client) Hangup

func (c *Client) Hangup() error

func (*Client) SendCommand

func (c *Client) SendCommand(op string, args ...string) (*Reply, error)

type Command

type Command struct {
	Op   string   `json:"o"`
	Args []string `json:"a"`
}

func MakeCommand

func MakeCommand(op string, args ...string) Command

type CommandHandler

type CommandHandler struct {
	// contains filtered or unexported fields
}

func NewCommandHandler

func NewCommandHandler(srv *CommandService) *CommandHandler

func (*CommandHandler) ServeHTTP

func (h *CommandHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*CommandHandler) WaitClose

func (h *CommandHandler) WaitClose()

type CommandService

type CommandService struct {
	// contains filtered or unexported fields
}

func NewCommandService

func NewCommandService(store Store) *CommandService

func (*CommandService) ExecCommand

func (srv *CommandService) ExecCommand(c Command) (*Reply, error)

type Reply

type Reply struct {
	Value any    `json:"v"`
	Type  string `json:"t"`
}

func NewReply

func NewReply(str string) *Reply

func NewReplyArray

func NewReplyArray(values []any) *Reply

func NewReplyErr

func NewReplyErr(str string) *Reply

func NewReplyInteger

func NewReplyInteger(i int64) *Reply

func NewReplyNil

func NewReplyNil() *Reply

func NewReplyOK

func NewReplyOK() *Reply

func (*Reply) Values

func (r *Reply) Values() []any

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(store Store) *Server

func (*Server) Shutdown

func (srv *Server) Shutdown(ctx context.Context) error

func (*Server) Start

func (srv *Server) Start(ctx context.Context, addr string) error

type StandardStore

type StandardStore struct {
	// contains filtered or unexported fields
}

func LoadStore

func LoadStore(reader io.Reader) (*StandardStore, error)

func LoadStoreFromFile

func LoadStoreFromFile(name string) (*StandardStore, error)

func NewStandardStore

func NewStandardStore() *StandardStore

func (*StandardStore) Delete

func (st *StandardStore) Delete(key string)

func (*StandardStore) Exists

func (st *StandardStore) Exists(key string) bool

func (*StandardStore) Flush

func (st *StandardStore) Flush()

func (*StandardStore) Get

func (st *StandardStore) Get(key string) string

func (*StandardStore) Keys

func (st *StandardStore) Keys() []string

func (*StandardStore) Set

func (st *StandardStore) Set(key string, value string)

func (*StandardStore) Size

func (st *StandardStore) Size() int64

type Store

type Store interface {
	Set(key string, value string)
	Get(key string) string
	Delete(key string)
	Exists(key string) bool
	Keys() []string
	Size() int64
	Flush()
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL