Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
6aa7f18d92
@ -7,17 +7,14 @@ import (
|
|||||||
/*
|
/*
|
||||||
Redis Lindex 命令用于通过索引获取列表中的元素。你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推
|
Redis Lindex 命令用于通过索引获取列表中的元素。你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推
|
||||||
*/
|
*/
|
||||||
func (this *Redis) Lindex(key string, v interface{}) (err error) {
|
func (this *Redis) Lindex(key string, index int64, v interface{}) (err error) {
|
||||||
cmd := redis.NewStringCmd(this.client.Context(), "LINDEX", key)
|
var (
|
||||||
this.client.Process(this.client.Context(), cmd)
|
resultvalue []byte
|
||||||
var _result []byte
|
)
|
||||||
if _result, err = cmd.Bytes(); err == nil {
|
if resultvalue, err = this.client.LIndex(this.client.Context(), key, index).Bytes(); err != nil {
|
||||||
if len(_result) == 0 {
|
|
||||||
err = redis.Nil
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = this.codec.Unmarshal(_result, v)
|
err = this.codec.Unmarshal(resultvalue, v)
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ type (
|
|||||||
MGet(v interface{}, keys ...string) (err error)
|
MGet(v interface{}, keys ...string) (err error)
|
||||||
INCRBY(key string, amount int64) (result int64, err error)
|
INCRBY(key string, amount int64) (result int64, err error)
|
||||||
/*List*/
|
/*List*/
|
||||||
Lindex(key string, value interface{}) (err error)
|
Lindex(key string, index int64, value interface{}) (err error)
|
||||||
Linsert(key string, isbefore bool, tager interface{}, value interface{}) (err error)
|
Linsert(key string, isbefore bool, tager interface{}, value interface{}) (err error)
|
||||||
Llen(key string) (result int, err error)
|
Llen(key string) (result int, err error)
|
||||||
LPop(key string, value interface{}) (err error)
|
LPop(key string, value interface{}) (err error)
|
||||||
@ -280,8 +280,8 @@ func UnLock(key string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*List*/
|
/*List*/
|
||||||
func Lindex(key string, value interface{}) (err error) {
|
func Lindex(key string, index int64, value interface{}) (err error) {
|
||||||
return defsys.Lindex(key, value)
|
return defsys.Lindex(key, index, value)
|
||||||
}
|
}
|
||||||
func Linsert(key string, isbefore bool, tager interface{}, value interface{}) (err error) {
|
func Linsert(key string, isbefore bool, tager interface{}, value interface{}) (err error) {
|
||||||
return defsys.Linsert(key, isbefore, tager, value)
|
return defsys.Linsert(key, isbefore, tager, value)
|
||||||
|
@ -7,17 +7,14 @@ import (
|
|||||||
/*
|
/*
|
||||||
Redis Lindex 命令用于通过索引获取列表中的元素。你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推
|
Redis Lindex 命令用于通过索引获取列表中的元素。你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推
|
||||||
*/
|
*/
|
||||||
func (this *RedisPipe) Lindex(key string, v interface{}) (err error) {
|
func (this *RedisPipe) Lindex(key string, index int64, v interface{}) (err error) {
|
||||||
cmd := redis.NewStringCmd(this.ctx, "LINDEX", key)
|
var (
|
||||||
this.client.Process(this.ctx, cmd)
|
resultvalue []byte
|
||||||
var _result []byte
|
)
|
||||||
if _result, err = cmd.Bytes(); err == nil {
|
if resultvalue, err = this.client.LIndex(this.ctx, key, index).Bytes(); err != nil {
|
||||||
if len(_result) == 0 {
|
|
||||||
err = redis.Nil
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = this.codec.Unmarshal(_result, v)
|
err = this.codec.Unmarshal(resultvalue, v)
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,8 +164,8 @@ func (this *Redis) INCRBY(key string, amount int64) (result int64, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*List*/
|
/*List*/
|
||||||
func (this *Redis) Lindex(key string, value interface{}) (err error) {
|
func (this *Redis) Lindex(key string, index int64, value interface{}) (err error) {
|
||||||
return this.client.Lindex(key, value)
|
return this.client.Lindex(key, index, value)
|
||||||
}
|
}
|
||||||
func (this *Redis) Linsert(key string, isbefore bool, tager interface{}, value interface{}) (err error) {
|
func (this *Redis) Linsert(key string, isbefore bool, tager interface{}, value interface{}) (err error) {
|
||||||
return this.client.Linsert(key, isbefore, tager, value)
|
return this.client.Linsert(key, isbefore, tager, value)
|
||||||
|
@ -7,13 +7,14 @@ import (
|
|||||||
/*
|
/*
|
||||||
Redis Lindex 命令用于通过索引获取列表中的元素。你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推
|
Redis Lindex 命令用于通过索引获取列表中的元素。你也可以使用负数下标,以 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推
|
||||||
*/
|
*/
|
||||||
func (this *Redis) Lindex(key string, v interface{}) (err error) {
|
func (this *Redis) Lindex(key string, index int64, v interface{}) (err error) {
|
||||||
cmd := redis.NewStringCmd(this.client.Context(), "LINDEX", key)
|
var (
|
||||||
this.client.Process(this.client.Context(), cmd)
|
resultvalue []byte
|
||||||
var _result []byte
|
)
|
||||||
if _result, err = cmd.Bytes(); err == nil {
|
if resultvalue, err = this.client.LIndex(this.client.Context(), key, index).Bytes(); err != nil {
|
||||||
err = this.codec.Unmarshal(_result, v)
|
return
|
||||||
}
|
}
|
||||||
|
err = this.codec.Unmarshal(resultvalue, v)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user