Skip to content

Commit

Permalink
add redis LPopN method
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderTreeTech committed Sep 14, 2021
1 parent eeb196b commit 9c900fe
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/database/redis/command.go
Expand Up @@ -289,6 +289,16 @@ func (r *Redis) LPop(ctx context.Context, key string) (value string, err error)
return
}

// LPopN removes and returns the N elements of the list stored at key
func (r *Redis) LPopN(ctx context.Context, key string, count int) (value []string, err error) {
err = r.breakers.Do(r.config.dbAddr, func() error {
reply, rerr := r.client.LPopCount(ctx, key, count).Result()
value = reply
return rerr
}, accept)
return
}

// LPush insert all the specified values at the head of the list stored at key
func (r *Redis) LPush(ctx context.Context, key string, values ...interface{}) (value int64, err error) {
err = r.breakers.Do(r.config.dbAddr, func() error {
Expand Down

0 comments on commit 9c900fe

Please sign in to comment.