Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for SetConnMaxLifetime (0.13 sec)

  1. src/database/sql/sql_test.go

    		t.Errorf("closes = %d; want 0", closes)
    	}
    	if g, w := db.numFreeConns(), 2; g != w {
    		t.Errorf("free conns = %d; want %d", g, w)
    	}
    
    	// Expire first conn
    	offset = 11 * time.Second
    	db.SetConnMaxLifetime(10 * time.Second)
    
    	tx, err = db.Begin()
    	if err != nil {
    		t.Fatal(err)
    	}
    	tx2, err = db.Begin()
    	if err != nil {
    		t.Fatal(err)
    	}
    	tx.Commit()
    	tx2.Commit()
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 18:42:28 UTC 2024
    - 111.6K bytes
    - Viewed (0)
  2. src/database/sql/sql.go

    	db.mu.Unlock()
    	if syncMaxIdle {
    		db.SetMaxIdleConns(n)
    	}
    }
    
    // SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
    //
    // Expired connections may be closed lazily before reuse.
    //
    // If d <= 0, connections are not closed due to a connection's age.
    func (db *DB) SetConnMaxLifetime(d time.Duration) {
    	if d < 0 {
    		d = 0
    	}
    	db.mu.Lock()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 01:16:53 UTC 2024
    - 103.6K bytes
    - Viewed (0)
Back to top