redix

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: MIT Imports: 13 Imported by: 0

README

Redix

CircleCI

可能是我毕业设计的一小部分,一个精简版 Redis,它只是个“小玩具”

支持的命令:

  • SET
  • SETNX
  • GET
  • INCR
  • INCRBY
  • DECR
  • DECRBY
  • KEYS
  • TTL
  • EXPIRE
  • DEL
  • FLUSHALL
  • FLUSHDB: 没有区分 db,所以直接调用的 FLUSHALL
  • AUTH
  • PING
  • QUIT
  • SHUTDOWN

安装

二进制

releases

Go Install
$ go install go.chensl.me/redix/cmd/redix-server@latest
go: downloading go.chensl.me/redix v0.1.0
$ redix-server # 数据默认存放在当前目录的 data 文件夹下
 _____          _ _
|  __ \        | (_)
| |__) |___  __| |___  __
|  _  // _ \/ _` | \ \/ /
| | \ \  __/ (_| | |>  <
|_|  \_\___|\__,_|_/_/\_\  commit=2f449de

{"level":"info","ts":1645346199.62673,"caller":"redix/redix.go:80","msg":"redix server started","host":"0.0.0.0","port":6380,"data_dir":"/Users/.../go/src/go.chensl.me/redix/data"}

使用 redis-cliiredis 连接:

$ redis-cli -p 6380
Docker
$ mkdir data
$ docker run -d -p 6380:6380 \
    --name redix \
    -v $PWD/data:/data \
    -e REDIX_DATA_DIR=/data \
    -e REDIX_PASSWORD=123456 \
    maolonglong/redix:latest

配置

可通过配置文件或环境变量进行配置(环境变量优先级更高),配置文件示例:config.yml

配置文件可放置在(按顺序查找):

  • 当前目录 config.yml
  • 用户目录 .redix.yml
  • /etc/redix/config.yml

可用配置和默认值:

  • REDIX_HOST: 0.0.0.0
  • REDIX_PORT: 6380
  • REDIX_PASSWORD: ""
  • REDIX_DATA_DIR: ./data

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandFunc

type CommandFunc func(c *Context)

type Context

type Context struct {
	Args [][]byte
	// contains filtered or unexported fields
}

func (*Context) AppendBulk

func (c *Context) AppendBulk(b []byte)

func (*Context) AppendBulkArray

func (c *Context) AppendBulkArray(bs [][]byte)

func (*Context) AppendError

func (c *Context) AppendError(s string)

func (*Context) AppendInt

func (c *Context) AppendInt(i int64)

func (*Context) AppendNull

func (c *Context) AppendNull()

func (*Context) AppendOK

func (c *Context) AppendOK()

func (*Context) ErrInvalidArgs

func (c *Context) ErrInvalidArgs()

func (*Context) ErrInvalidExp

func (c *Context) ErrInvalidExp()

func (*Context) ErrInvalidInt

func (c *Context) ErrInvalidInt()

func (*Context) ErrSyntax

func (c *Context) ErrSyntax()

func (*Context) ErrUnknown

func (c *Context) ErrUnknown(err error)

type Server

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

func New added in v0.1.1

func New() (*Server, error)

func (*Server) Cleanup added in v0.1.1

func (s *Server) Cleanup() error

func (*Server) Run

func (s *Server) Run() error

Directories

Path Synopsis
cmd
internal
pkg
server module

Jump to

Keyboard shortcuts

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