Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpireFunc ¶
type ExpireFunc func(interface{})
type Pool ¶
type Pool struct { TTL time.Duration NewFunc func() (interface{}, error) ExpireFunc func(interface{}) // contains filtered or unexported fields }
Pool 并发安全的对象复用池
func New ¶
func New(ttl time.Duration, newFunc NewFunc, expireFunc ...ExpireFunc) *Pool
New 创建对象池 注意: ttl = 0: 表示不过期。 ttl < 0: 使用后立即过期 ttl > 0: 设置的过期时间
type SyncPool ¶
type SyncPool struct {
// contains filtered or unexported fields
}
func NewSyncPool ¶
func NewSyncPool(newFunc func() interface{}, init func(interface{})) *SyncPool
NewSyncPool 创建对象池 newFunc:创建对象的方法 init: 对象被创建后,返回之前,调用该方法初始化对象
Click to show internal directories.
Click to hide internal directories.