Skip to content

Commit

Permalink
fix: postgres cache cannot assign requested address
Browse files Browse the repository at this point in the history
  • Loading branch information
Anonymous committed Aug 19, 2024
1 parent 2f3d0ae commit f51bf04
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions storage/cache/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ import (
"moul.io/zapgorm2"
)

const (
maxIdleConns = 64
maxOpenConns = 64
maxLifetime = time.Minute
)

const (
// ItemNeighbors is sorted set of neighbors for each item.
// Global item neighbors - item_neighbors/{item_id}
Expand Down Expand Up @@ -343,6 +349,9 @@ func Open(path, tablePrefix string) (Database, error) {
); err != nil {
return nil, errors.Trace(err)
}
database.client.SetMaxIdleConns(maxIdleConns)
database.client.SetMaxOpenConns(maxOpenConns)
database.client.SetConnMaxLifetime(maxLifetime)
database.gormDB, err = gorm.Open(postgres.New(postgres.Config{Conn: database.client}), storage.NewGORMConfig(tablePrefix))
if err != nil {
return nil, errors.Trace(err)
Expand Down

0 comments on commit f51bf04

Please sign in to comment.