aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/main.go b/main.go
index 8edf10f..5e56280 100644
--- a/main.go
+++ b/main.go
@@ -7,7 +7,6 @@ import (
"net"
"os"
"strings"
- "time"
)
@@ -18,9 +17,9 @@ type handlerFunc func(net.Conn, []string)
var commandRegistry = map[string]handlerFunc{
"GET": handleGet,
"SET": handleSet,
- "DEL": handleDel,
+// "DEL": handleDel,
"EXISTS": handleExists,
- "INCR": handleIncr,
+/* "INCR": handleIncr,
"DECR": handleDecr,
"PING": handlePing,
"FLUSHALL": handleFlushall,
@@ -38,12 +37,20 @@ var commandRegistry = map[string]handlerFunc{
"TYPE": handleType,
"DBSIZE": handleDbsize,
"KEYS": handleKeys,
- "LREM": handleLrem,
+ "LREM": handleLrem,*/
}
func main() {
- db = RedisDB{data: make(map[string]Item)}
+ numShards := 16
+ shards := make([]*Shard, numShards)
+ for i := 0; i < numShards; i++ {
+ shards[i] = &Shard{
+ data: make(map[string]Item),
+ }
+}
+ db = RedisDB{shards: shards}
+/*
go func() {
ticker := time.NewTicker(1 * time.Second)
for range ticker.C {
@@ -56,7 +63,7 @@ func main() {
db.mu.Unlock()
}
}()
-
+*/
listener, err := net.Listen("tcp", ":6379")
if err != nil {
fmt.Println("error starting server: ", err)