mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-11-15 14:50:21 +01:00
Fixes issue #7. mtredisalize implements Redis PING command.
This commit is contained in:
parent
05a95e4f7d
commit
75b2496fa6
|
@ -13,6 +13,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
redisOk = []byte("+OK\r\n")
|
redisOk = []byte("+OK\r\n")
|
||||||
|
redisPong = []byte("+PONG\r\n")
|
||||||
redisError = []byte("-ERR\r\n")
|
redisError = []byte("-ERR\r\n")
|
||||||
redisNoSuchBlock = []byte("$-1\r\n")
|
redisNoSuchBlock = []byte("$-1\r\n")
|
||||||
redisCrnl = []byte("\r\n")
|
redisCrnl = []byte("\r\n")
|
||||||
|
@ -130,6 +131,14 @@ func (c *Connection) Hkeys(hash []byte) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Connection) Ping() bool {
|
||||||
|
if _, err := c.conn.Write(redisPong); err != nil {
|
||||||
|
logError(err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Connection) HSpatial(hash, first, second []byte) bool {
|
func (c *Connection) HSpatial(hash, first, second []byte) bool {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxBulkStringSize = 8 * 1024 * 1024
|
const maxBulkStringSize = 8 * 1024 * 1024
|
||||||
|
@ -130,6 +131,7 @@ type RedisCommands interface {
|
||||||
Exec() bool
|
Exec() bool
|
||||||
Hkeys(hash []byte) bool
|
Hkeys(hash []byte) bool
|
||||||
HSpatial(hash, first, second []byte) bool
|
HSpatial(hash, first, second []byte) bool
|
||||||
|
Ping() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type RedisCommandExecutor struct {
|
type RedisCommandExecutor struct {
|
||||||
|
@ -173,7 +175,7 @@ func (rce *RedisCommandExecutor) execute() bool {
|
||||||
log.Printf("WARN: Too less argument for command.")
|
log.Printf("WARN: Too less argument for command.")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
cmd := asString(rce.args[0])
|
cmd := strings.ToUpper(asString(rce.args[0]))
|
||||||
switch cmd {
|
switch cmd {
|
||||||
case "HGET":
|
case "HGET":
|
||||||
if l < 3 {
|
if l < 3 {
|
||||||
|
@ -235,6 +237,9 @@ func (rce *RedisCommandExecutor) execute() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return rce.commands.HSpatial(hash, first, second)
|
return rce.commands.HSpatial(hash, first, second)
|
||||||
|
|
||||||
|
case "PING":
|
||||||
|
return rce.commands.Ping()
|
||||||
}
|
}
|
||||||
log.Printf("WARN: unknown command: '%s'\n", cmd)
|
log.Printf("WARN: unknown command: '%s'\n", cmd)
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue
Block a user