redis

package
v0.0.0-...-3d0adf2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : redis.go # Created : 2019/1/9 18:49 # Last Modified : 2019/1/9 18:49 # Describe : # # ====================================================

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 返回redis的客户端

func NewClient

func NewClient(addrs []string, password string) (*Client, error)

NewClient 新建一个redis的客户端,addr为集群地址,如果只有一个默认单机

func (*Client) Add

func (c *Client) Add(ctx context.Context, k string, v []byte, ttl int64) error

Add 如果key不存在则放入value,如果存在返回ErrKeyExsit

func (*Client) Append

func (c *Client) Append(ctx context.Context, k string, v []byte) error

Append 将value添加到set之中

func (*Client) Close

func (c *Client) Close() error

Close 关闭与redis的连接

func (*Client) Del

func (c *Client) Del(ctx context.Context, k string) error

Del 删除一个key的value

func (*Client) Discard

func (c *Client) Discard() error

Discard 将管道中的操作列表清空,用于取消事务

func (*Client) Exec

func (c *Client) Exec() ([]interface{}, error)

Exec 执行管道中缓存的操作,用于提交事务

func (*Client) Expire

func (c *Client) Expire(ctx context.Context, k string, ttl int64) error

Expire 给key设置过期时间,单位(s)

func (*Client) Get

func (c *Client) Get(ctx context.Context, s string) ([]byte, error)

Get 按key获取value,如果不存在返回ErrCacheMiss

func (*Client) Incr

func (c *Client) Incr(ctx context.Context, k string) (int64, error)

Incr 将key的value+1

func (*Client) IsMember

func (c *Client) IsMember(ctx context.Context, k string, v []byte) (bool, error)

IsMember value是否是key的set中的值

func (*Client) LLen

func (c *Client) LLen(ctx context.Context, k string) (int64, error)

LLen 查看key的list的长度

func (*Client) LPop

func (c *Client) LPop(ctx context.Context, k string) ([]byte, error)

LPop 在list中移除最左的数据

func (*Client) Pipeline

func (c *Client) Pipeline() *Client

Pipeline 返回一个管道,用于开启事务

func (*Client) Put

func (c *Client) Put(ctx context.Context, k string, v []byte, ttl int64) error

Put 将数据放入缓存,ttl为过期时间 单位(s)

func (*Client) RPush

func (c *Client) RPush(ctx context.Context, k string, v []byte) error

RPush 将数据push到key的list中

func (*Client) SMembers

func (c *Client) SMembers(ctx context.Context, k string) ([]string, error)

SMembers 列出set的所有的值

func (*Client) SRem

func (c *Client) SRem(ctx context.Context, k string, v []byte) error

SRem 在set中移除特定的value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL