Categorygithub.com/Laisky/go-redis
modulepackage
1.1.0
Repository: https://github.com/laisky/go-redis.git
Documentation: pkg.go.dev

# README

Redis Tools

Some redis utils depend on https://github.com/go-redis/redis

import (
    gredis "github.com/Laisky/go-redis"
    "github.com/go-redis/redis"
)

func main() {
    rtils := NewRedisUtils(redis.NewClient(&redis.Options{}))
}

Features

  • getset.go: common utils of get/set
  • sync.go: distributed locks

# Functions

IsNil is nil in redis.
NewRedisUtils wrap redis client with utils.
SetLogger set go-redis logger.
WithMutexBlockingLock set whether blocking lock.
WithMutexClientID set client id.
WithMutexLogger set lock's expiration.
WithMutexRefreshInterval set lock refreshing interval.
WithMutexSpinInterval set lock spin interval.
WithMutexTTL set lock's expiration.
WithSemaphoreBlockingLock set whether blocking lock.
WithSemaphoreClientID set client id.
WithSemaphoreLogger set lock's expiration.
WithSemaphoreRefreshInterval set lock refreshing interval.
WithSemaphoreSpinInterval set lock spin interval.
WithSemaphoreTTL set lock's expiration.

# Constants

DefaultKeyPrefix default prefix of key in redis.
KeyExp1Day 1day.
KeyExpImmortal nolimit.
ScanCount how many items return by each scan.
Pop time.

# Structs

Utils utils enhancemant for redis.

# Interfaces

mutexType distributed mutex Redis keys: `/rtils/sync/mutex/<lock_id>/<client_id>` Implementations: 1.
Rank Use the ordered set of redis to implement dynamic ranking.
RdbIntCmdItf string result.
RdbItf redis SDK.
RdbScanCmdItf string result.
RdbSliceCmdItf string result.
RdbStatusCmdItf string result.
RdbStringCmdItf string result.
semaphore distributed fair semaphore Redis keys: `/rtils/sync/sema/<lock_id>/` * cids/: client_id -> ts, all clients * owners/: client_id -> counter, all clients acquired lock * counter: you can specified client_id by `WithSemaphoreClientID`.

# Type aliases

GetItemBlockingOptionFunc optional arguments for GetItemBlocking.
MutexOptionFunc options for mutex.
SemaphoreOptionFunc options for semaphore.