mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-05 08:46:56 +08:00
reformat code
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
|
||||
[中文版](https://github.com/HDT3213/godis/blob/master/README_CN.md)
|
||||
|
||||
`Godis` is a simple implementation of Redis Server, which intents to provide an example of writing a high concurrent middleware using golang.
|
||||
`Godis` is a simple implementation of Redis Server, which intents to provide an example of writing a high concurrent
|
||||
middleware using golang.
|
||||
|
||||
Please be advised, NEVER think about using this in production environment.
|
||||
|
||||
This repository implemented most features of redis, including 5 data structures, ttl, publish/subscribe, AOF persistence and server side cluster mode.
|
||||
This repository implemented most features of redis, including 5 data structures, ttl, publish/subscribe, AOF persistence
|
||||
and server side cluster mode.
|
||||
|
||||
If you could read Chinese, you can find more details in [My Blog](https://www.cnblogs.com/Finley/category/1598973.html).
|
||||
|
||||
@@ -35,8 +37,7 @@ peers localhost:7379,localhost:7389 // other node in cluster
|
||||
self localhost:6399 // self address
|
||||
```
|
||||
|
||||
We provide node1.conf and node2.conf for demonstration.
|
||||
use following command line to start a two-node-cluster:
|
||||
We provide node1.conf and node2.conf for demonstration. use following command line to start a two-node-cluster:
|
||||
|
||||
```bash
|
||||
CONFIG=node1.conf ./godis-darwin &
|
||||
|
@@ -2,8 +2,8 @@ Godis 是一个用 Go 语言实现的 Redis 服务器。本项目旨在为尝试
|
||||
|
||||
**请注意:不要在生产环境使用使用此项目**
|
||||
|
||||
Godis 实现了 Redis 的大多数功能,包括5种数据结构、TTL、发布订阅以及 AOF 持久化。可以在[我的博客](https://www.cnblogs.com/Finley/category/1598973.html)了解更多关于 Godis 的信息。
|
||||
|
||||
Godis 实现了 Redis 的大多数功能,包括5种数据结构、TTL、发布订阅以及 AOF 持久化。可以在[我的博客](https://www.cnblogs.com/Finley/category/1598973.html)了解更多关于
|
||||
Godis 的信息。
|
||||
|
||||
# 运行 Godis
|
||||
|
||||
|
@@ -37,4 +37,3 @@ func RenameNx(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply {
|
||||
}
|
||||
return cluster.Relay(srcPeer, c, args)
|
||||
}
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package list
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func ToString(list *LinkedList) string {
|
||||
|
@@ -106,7 +106,6 @@ func (locks *Locks)RLocks(keys ...string) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (locks *Locks) UnLocks(keys ...string) {
|
||||
indices := locks.toLockIndices(keys, true)
|
||||
for _, index := range indices {
|
||||
|
@@ -6,7 +6,6 @@ const (
|
||||
maxLevel = 16
|
||||
)
|
||||
|
||||
|
||||
type Element struct {
|
||||
Member string
|
||||
Score float64
|
||||
|
@@ -214,7 +214,6 @@ func (sortedSet *SortedSet) RemoveByScore(min *ScoreBorder, max *ScoreBorder)int
|
||||
return int64(len(removed))
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 0-based rank, [start, stop)
|
||||
*/
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package tcp
|
||||
|
||||
import (
|
||||
"net"
|
||||
"context"
|
||||
"net"
|
||||
)
|
||||
|
||||
type HandleFunc func(ctx context.Context, conn net.Conn)
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package files
|
||||
|
||||
import (
|
||||
"mime/multipart"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"os"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"os"
|
||||
"path"
|
||||
)
|
||||
|
||||
func GetSize(f multipart.File) (int, error) {
|
||||
|
@@ -15,5 +15,3 @@ func (b *AtomicBool)Set(v bool) {
|
||||
atomic.StoreUint32((*uint32)(b), 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -310,7 +310,6 @@ func (client *Client) handleRead() error {
|
||||
client.finishRequest(reply)
|
||||
}
|
||||
|
||||
|
||||
// finish reply
|
||||
expectedArgsCount = 0
|
||||
receivedCount = 0
|
||||
|
@@ -110,7 +110,6 @@ func (r *IntReply) ToBytes() []byte {
|
||||
return []byte(":" + strconv.FormatInt(r.Code, 10) + CRLF)
|
||||
}
|
||||
|
||||
|
||||
/* ---- Error Reply ---- */
|
||||
|
||||
type ErrorReply interface {
|
||||
|
@@ -5,15 +5,15 @@ package tcp
|
||||
*/
|
||||
|
||||
import (
|
||||
"net"
|
||||
"context"
|
||||
"bufio"
|
||||
"context"
|
||||
"github.com/HDT3213/godis/src/lib/logger"
|
||||
"sync"
|
||||
"io"
|
||||
"github.com/HDT3213/godis/src/lib/sync/atomic"
|
||||
"time"
|
||||
"github.com/HDT3213/godis/src/lib/sync/wait"
|
||||
"io"
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type EchoHandler struct {
|
||||
@@ -21,9 +21,8 @@ type EchoHandler struct {
|
||||
closing atomic.AtomicBool
|
||||
}
|
||||
|
||||
func MakeEchoHandler()(*EchoHandler) {
|
||||
return &EchoHandler{
|
||||
}
|
||||
func MakeEchoHandler() *EchoHandler {
|
||||
return &EchoHandler{}
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
|
@@ -45,7 +45,6 @@ func ListenAndServe(cfg *Config, handler tcp.Handler) {
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
// listen port
|
||||
logger.Info(fmt.Sprintf("bind: %s, start listening...", cfg.Address))
|
||||
defer func() {
|
||||
|
Reference in New Issue
Block a user