pool

package
v0.4.22 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool interface {
	// AcquireString 从资源池中获取一个资源
	AcquireString() (ResourceID, string, error)
	// ReleaseString 释放一个资源到资源池
	ReleaseString(ResourceID) error
	// Clear 清空资源池
	Clear()
	// RefreshConfigs 刷新配置
	RefreshConfig(config.ServicePoolConfig) error
}

Pool 资源池接口

type RedisPool

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

RedisPool 实现 Pool 接口

func NewRedisPool

func NewRedisPool(ctx context.Context, cli *redis.Client, rdsKey string, conf config.ServicePoolConfig) *RedisPool

NewRedisPool 创建一个新的 服务池 每次新建一个服务池时,会清空原有服务池

func (*RedisPool) Acquire

func (rp *RedisPool) Acquire() (*redis.Z, error)

Acquire 从资源池中获取一个资源, 返回值为redis.z 不需要key

func (*RedisPool) AcquireString added in v0.2.4

func (rp *RedisPool) AcquireString() (ResourceID, string, error)

AcquireString 从资源池中获取一个资源, 返回值为string

func (*RedisPool) Clear

func (rp *RedisPool) Clear()

Clear 清空资源池

func (*RedisPool) RefreshConfig added in v0.4.14

func (rp *RedisPool) RefreshConfig(newConf config.ServicePoolConfig) error

RefreshConfig 刷新配置

func (*RedisPool) Release

func (rp *RedisPool) Release(rz *redis.Z) error

Release 释放一个资源到资源池, v为redis.z

func (*RedisPool) ReleaseString added in v0.2.4

func (rp *RedisPool) ReleaseString(id string) error

ReleaseString 释放一个资源到资源池, v为string

type ResourceID added in v0.4.17

type ResourceID = string

ResourceID 资源ID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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