byor

package module
v0.0.0-...-7dfbc59 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: CC0-1.0 Imports: 16 Imported by: 0

README

Build your own Redis

Programming exercise to brush up Golang skills and get basic understanding of Redis internals.

This follows Build your own Redis guide religiously with few caveats.

  • Uses Go instead of C
  • Uses net package for socket programming instead of raw syscalls
  • Uses goroutines instead of epoll for implementing concurrency

To run server & client use

> go run build/byor-server/main.go -port=:6060

> go run build/byor-client/main.go -port=:6060

Documentation

Index

Constants

View Source
const (
	RES_OK  = 0 // Status OK
	RES_ERR = 1 // Status Error
	RES_NX  = 2 // Status Not Found
)
View Source
const (
	MAX_LOAD_FACTOR   = 0.75
	MAX_RESIZING_WORK = 128
)
View Source
const (
	LEN_BYTES = 4
	// Max int32 size minus 4 to account for strings number prefix
	// as max length of data sent can be MaxInt32
	MAX_STR_LENGTH = math.MaxInt32 - LEN_BYTES
)
View Source
const (
	SER_NIL = 0
	SER_ERR = 1
	SER_STR = 2
	SER_INT = 3
	SER_ARR = 4
)
View Source
const (
	MAX_BYTES = math.MaxInt32
)

Variables

This section is empty.

Functions

func Client

func Client(port string) error

func Decoder

func Decoder(rdr io.Reader) ([]byte, error)

func Encoder

func Encoder(wrt io.Writer, cmd []byte) error

func Server

func Server(port string) error

Types

type HMap

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

func NewHashMap

func NewHashMap(size int32) *HMap

func (*HMap) Clear

func (hm *HMap) Clear()

func (*HMap) Delete

func (hm *HMap) Delete(key string)

func (*HMap) Get

func (hm *HMap) Get(key string) string

func (*HMap) Keys

func (hm *HMap) Keys() []string

func (*HMap) Put

func (hm *HMap) Put(key, val string)

func (*HMap) Size

func (hm *HMap) Size() int32

Directories

Path Synopsis
build

Jump to

Keyboard shortcuts

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