From 8d64d44e08ee2a1a8ff3a355a91de2c63bc90b39 Mon Sep 17 00:00:00 2001 From: loshiqi <553578653@qq.com> Date: Mon, 19 Sep 2022 14:35:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0rpop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/list.go b/list.go index 6e610b4..2bdc648 100644 --- a/list.go +++ b/list.go @@ -18,7 +18,20 @@ func Rpush(key string, field interface{}) (int64, error) { return redisdb.Int64(reply, nil) } +//移除列表的最后一个元素,返回值为移除的元素。 +func Rpop(key string) ([]byte, error) { + c := GetConn() + + ret, err := c.Do("RPOP", key) + CloseConn(c) + + if err != nil { + return nil, err + } + reply, err := redisdb.Bytes(ret, err) + return reply, err +} //list 头部增加值 func Lpush(key string, field interface{}) (int64, error) {