Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement cURL Handle Caching #864

Merged
merged 2 commits into from
Nov 20, 2023
Merged

Conversation

JSlush611
Copy link
Contributor

This PR implements caching of the cURL handle created by curl_init() to increase performance and reduce system overhead that comes with repeated creation and destruction of curl handles.

It modifies the getCurlHandle() method and only calls curl_init() once instead of each call to send(). It also removes now unnecessary calls to curl_close() in order to retain the pointer to the cached handle.

Calls to curl_init call curl_easy_init under the hood - the cURL documentation for curl_easy_init says "[You are]...encouraged to reuse easy handles for repeated transfers..." (see https://curl.se/libcurl/c/curl_easy_init.html). This PR implements this suggestion. The documentation for cURL also states "...reusing handles is a key to good performance with libcurl."

@patinthehat

@freekmurze freekmurze merged commit 7922296 into spatie:main Nov 20, 2023
21 checks passed
@freekmurze
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants