Пример #1
0
func NewCachePool(cfg config.CacheConfig) (pool *CachePool) {
	pool = &CachePool{pools.NewRoundRobin(int(cfg.PoolSize), time.Duration(cfg.IdleTimeOut*1e9))}
	pool.Open(CacheCreator(cfg))
	tmp := make([]*cacheInstance, cfg.PoolSize)
	for i := uint16(0); i < cfg.PoolSize; i++ {
		tmp[i] = pool.Get()
	}
	for i := uint16(0); i < cfg.PoolSize; i++ {
		tmp[i].Recycle()
	}
	return pool
}
Пример #2
0
func NewDBPool(cfg config.MySQLConfig) (pool *DbPool) {
	pool = &DbPool{pools.NewRoundRobin(int(cfg.PoolSize), time.Duration(cfg.IdleTimeOut*1e9))}
	pool.Open(DBCreator(cfg))
	return pool
}