-
Notifications
You must be signed in to change notification settings - Fork 125
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
Cache support #4
Comments
I like where you are going with this. Caching would be great however we have to be careful what we implement as we don't want the sdk to get very bloated. |
Yeah maybe caching should be left to the discretion of the app built with the SDK. Good thing is that Guzzle Cache is embedded already so there is a way to extend it. |
For now, with the way the SDK is structured (this will probably improve soon) the best way would be to subclass the main Infusionsoft class, override <?php
use Guzzle\Http\Client;
use Doctrine\Common\Cache\FilesystemCache;
use Guzzle\Cache\DoctrineCacheAdapter;
use Guzzle\Plugin\Cache\CachePlugin;
use Guzzle\Plugin\Cache\DefaultCacheStorage;
class SubInfusionsoft extends \Infusionsoft\Infusionsoft {
/**
* @return \Guzzle\Http\Client
*/
public function getHttpClient()
{
$httpClient = new Client();
$cachePlugin = new CachePlugin(array(
'storage' => new DefaultCacheStorage(
new DoctrineCacheAdapter(
new FilesystemCache('/path/to/cache/files')
)
)
));
$httpClient->addSubscriber($cachePlugin);
return $httpClient;
}
} Not ideal, but I'm looking to decouple the HTTP client a bit more to make it easier to do things like this in the future. Being able to customize the client is huge, especially for things like caching, inspecting requests via Runscope, or even other HTTP clients. |
Now that we have decoupled the HTTP client a little more, this should be easier. Probably even easier if we make the switch to Guzzle 4. But we could now work on getting this easier to implement by default. |
As we're moving to using GH Issues more for actual issues, I'm going to close this out. If anyone wants to create a pull request please do so, but we've added this on the list of new features to consider in future versions of the SDK. |
This is more a suggestion than a issue. I know that guzzle has a cache plugin. It will be great to see caching implemented in this sdk to speed up calls, as some of the call to isoft can be really time consuming and API has a rate limit. Thanks!
The text was updated successfully, but these errors were encountered: