pool

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoPool

type GoPool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

GoPool golang资源池

func NewGoPool

func NewGoPool() *GoPool

NewGoPool 创建一个golang资源池

func (*GoPool) Acquire

func (gp *GoPool) Acquire() (interface{}, error)

Acquire 从资源池中获取一个资源

func (*GoPool) AcquireDecode

func (gp *GoPool) AcquireDecode(v interface{}) error

AcquireDecode 从资源池中获取一个资源, 并解析到v

func (*GoPool) AcquireString added in v0.2.4

func (gp *GoPool) AcquireString() (string, error)

AcquireString 从资源池中获取一个资源

func (*GoPool) Clear

func (gp *GoPool) Clear()

Clear 清空资源池

func (*GoPool) Release

func (gp *GoPool) Release(v interface{}) error

Release 释放一个资源到资源池

func (*GoPool) ReleaseEncode

func (gp *GoPool) ReleaseEncode(v interface{}) error

ReleaseEncode 释放一个资源到资源池

func (*GoPool) ReleaseString added in v0.2.4

func (gp *GoPool) ReleaseString(v string) error

ReleaseString 释放一个资源到资源池

type Pool

type Pool interface {
	// Acquire 从资源池中获取一个资源
	Acquire() (interface{}, error)
	// Release 释放一个资源到资源池
	Release(interface{}) error
	// AcquireDecode 从资源池中获取一个资源
	AcquireDecode(v interface{}) error
	// ReleaseEncode 释放一个资源到资源池
	ReleaseEncode(v interface{}) error
	// AcquireString 从资源池中获取一个资源
	AcquireString() (string, error)
	// ReleaseString 释放一个资源到资源池
	ReleaseString(string) error
	// Clear 清空资源池
	Clear()
}

Pool 资源池接口

type RedisPool

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

RedisPool redis资源池

func NewRedisPool

func NewRedisPool(ctx context.Context, cli *redis.Client, rdsPoolKey string) *RedisPool

NewRedisPool 创建一个redis资源池

func (*RedisPool) Acquire

func (rp *RedisPool) Acquire() (interface{}, error)

Acquire 从资源池中获取一个资源, 返回值为[]byte

func (*RedisPool) AcquireDecode

func (rp *RedisPool) AcquireDecode(v interface{}) error

AcquireDecode 从资源池中获取一个资源, 并json解析到v

func (*RedisPool) AcquireString added in v0.2.4

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

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

func (*RedisPool) Clear

func (rp *RedisPool) Clear()

Clear 清空资源池

func (*RedisPool) Release

func (rp *RedisPool) Release(v interface{}) error

Release 释放一个资源到资源池, v为[]byte或string

func (*RedisPool) ReleaseEncode

func (rp *RedisPool) ReleaseEncode(v interface{}) error

ReleaseEncode 释放一个资源到资源池, 并json编码

func (*RedisPool) ReleaseString added in v0.2.4

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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