Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use GuzzleHttp\Exception\BadResponseException;
use GuzzleHttp\HandlerStack;
use Kevinrob\GuzzleCache\CacheMiddleware;
use Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface;
use Kevinrob\GuzzleCache\Strategy\PublicCacheStrategy;
use LaunchDarkly\FeatureFlag;
use LaunchDarkly\FeatureRequester;
Expand Down Expand Up @@ -35,7 +36,10 @@ public function __construct($baseUri, $sdkKey, $options)
$this->_logger = $options['logger'];
$stack = HandlerStack::create();
if (class_exists('Kevinrob\GuzzleCache\CacheMiddleware')) {
$stack->push(new CacheMiddleware(new PublicCacheStrategy(isset($options['cache']) ? $options['cache'] : null)), 'cache');
$cacheOption = isset($options['cache']) ? $options['cache'] : null;
$cacheOption instanceof CacheStrategyInterface
? $stack->push(new CacheMiddleware($cacheOption), 'cache')
: $stack->push(new CacheMiddleware(new PublicCacheStrategy($cacheOption)), 'cache');
} elseif (!$this->_loggedCacheNotice) {
$this->_logger->info("GuzzleFeatureRequester is not using an HTTP cache because Kevinrob\GuzzleCache\CacheMiddleware was not installed");
$this->_loggedCacheNotice = true;
Expand Down