saRedis

package
v0.0.0-...-b2602dc Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

README

saRedis

介绍

redis二次封装

功能
  1. 基本操作
  2. 分布式锁

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

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

func (*Lock) Unlock

func (lock *Lock) Unlock() (err error)

type Redis

type Redis struct {
	*redis.Pool
	Project string //默认不会在key上面拼接,如果需要区分项目,需要手动拼接
}

func Init

func Init(uri string, pass string, db int) (r *Redis, err error)

func (Redis) Clear

func (r Redis) Clear(k string) error

func (Redis) Do

func (r Redis) Do(command string, args ...interface{}) (res interface{}, err error)

func (Redis) Get

func (r Redis) Get(k string) (interface{}, error)

func (Redis) GetInt64

func (r Redis) GetInt64(k string) (int64, error)

func (Redis) GetObj

func (r Redis) GetObj(k string, objPtr interface{}) error

func (Redis) GetString

func (r Redis) GetString(k string) (string, error)

func (Redis) IsError

func (r Redis) IsError(err error) bool

func (Redis) Set

func (r Redis) Set(k string, v interface{}, expire time.Duration) error

func (Redis) SetObj

func (r Redis) SetObj(k string, objPtr interface{}, expire time.Duration) error

func (Redis) TryLock

func (r Redis) TryLock(resource string, timeoutSecond int) (lock *Lock, err error)

func (Redis) TryLockWithMinTime

func (r Redis) TryLockWithMinTime(resource string, minTimeSecond int) (lock *Lock, err error)

func (Redis) WriteExpireAndNotExist

func (r Redis) WriteExpireAndNotExist(key, value string, expireTime int64) (ok bool)

Jump to

Keyboard shortcuts

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