-
Noobs question: for client objects like s3 client, kms client, should I create new client object on demand or should I cache one client object and reuse it whenever possible? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It's optimal to create one client object (per service) and reuse it wherever possible. In platforms like Lambda, initialisation is recommended to be done outside of the handler function to slightly optimise the code for future invocations. If you're using a service object pattern within Go, the client is typically stored within the service and used by any associated methods that need it. |
Beta Was this translation helpful? Give feedback.
It's optimal to create one client object (per service) and reuse it wherever possible.
In platforms like Lambda, initialisation is recommended to be done outside of the handler function to slightly optimise the code for future invocations. If you're using a service object pattern within Go, the client is typically stored within the service and used by any associated methods that need it.