You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

engine_maxlife.go 643B

12345678910111213141516171819202122
  1. // Copyright 2017 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build go1.6
  5. package xorm
  6. import "time"
  7. // SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
  8. func (engine *Engine) SetConnMaxLifetime(d time.Duration) {
  9. engine.db.SetConnMaxLifetime(d)
  10. }
  11. // SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
  12. func (eg *EngineGroup) SetConnMaxLifetime(d time.Duration) {
  13. eg.Engine.SetConnMaxLifetime(d)
  14. for i := 0; i < len(eg.slaves); i++ {
  15. eg.slaves[i].SetConnMaxLifetime(d)
  16. }
  17. }