mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-23 16:50:18 +01:00
Fixed and simplified redis network code.
This commit is contained in:
parent
60f43c9f52
commit
d6ddd047a4
@ -21,8 +21,6 @@ var (
|
|||||||
redisQueued = []byte("+QUEUED\r\n")
|
redisQueued = []byte("+QUEUED\r\n")
|
||||||
redisTrue = []byte(":1\r\n")
|
redisTrue = []byte(":1\r\n")
|
||||||
redisFalse = []byte(":0\r\n")
|
redisFalse = []byte(":0\r\n")
|
||||||
redisZero = []byte("0\r\n")
|
|
||||||
redisOne = []byte("1\r\n")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Connection struct {
|
type Connection struct {
|
||||||
@ -66,11 +64,7 @@ func (c *Connection) Hdel(hash, key []byte) bool {
|
|||||||
return c.writeError(err)
|
return c.writeError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if success {
|
return c.writeBool(success)
|
||||||
return c.writeMessage(redisOne)
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.writeMessage(redisZero)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Connection) Hget(hash, key []byte) bool {
|
func (c *Connection) Hget(hash, key []byte) bool {
|
||||||
@ -153,8 +147,7 @@ func (c *Connection) Hkeys(hash []byte) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Connection) Ping() bool {
|
func (c *Connection) Ping() bool {
|
||||||
_, err := c.conn.Write(redisPong)
|
return c.writeMessage(redisPong)
|
||||||
return logError(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Connection) HSpatial(hash, first, second []byte) bool {
|
func (c *Connection) HSpatial(hash, first, second []byte) bool {
|
||||||
@ -183,23 +176,18 @@ func (c *Connection) HSpatial(hash, first, second []byte) bool {
|
|||||||
|
|
||||||
func (c *Connection) writeError(err error) bool {
|
func (c *Connection) writeError(err error) bool {
|
||||||
logError(err)
|
logError(err)
|
||||||
_, err = c.conn.Write(redisError)
|
return c.writeMessage(redisError)
|
||||||
return logError(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Connection) writeEmptyArray() bool {
|
func (c *Connection) writeEmptyArray() bool {
|
||||||
_, err := c.conn.Write(redisEmptyArray)
|
return c.writeMessage(redisEmptyArray)
|
||||||
return logError(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Connection) writeBool(b bool) bool {
|
func (c *Connection) writeBool(b bool) bool {
|
||||||
var err error
|
|
||||||
if b {
|
if b {
|
||||||
_, err = c.conn.Write(redisTrue)
|
return c.writeMessage(redisTrue)
|
||||||
} else {
|
|
||||||
_, err = c.conn.Write(redisFalse)
|
|
||||||
}
|
}
|
||||||
return logError(err)
|
return c.writeMessage(redisFalse)
|
||||||
}
|
}
|
||||||
|
|
||||||
func redisLength(prefix byte, s int) []byte {
|
func redisLength(prefix byte, s int) []byte {
|
||||||
|
Loading…
Reference in New Issue
Block a user