planetscale/database-js

what is the use of connect.refresh

shiyuhang0 opened this issue · 1 comments

I find there is a refresh method in connect

const config = {
  host: '<host>',
  username: '<user>',
  password: '<password>'
}

const conn = connect(config)
conn.refresh()

I wonder the use of the refresh and in which situation I need to call this method.

I looked through the official doc and this repo but not find the answer

Think of it as creating a new session. For context, the session is used for keeping an identifier for a connection over HTTP and keeps that connection warm. This session is implicitly created whenever a query is executed and sent on subsequent queries. You can call refresh immediately after connecting because that will warm up the connection so your first query is faster.