File tree Expand file tree Collapse file tree 1 file changed +19
-13
lines changed Expand file tree Collapse file tree 1 file changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -491,22 +491,28 @@ private function cachedCall(
491491 return $ this ->call ($ method , $ uri , $ body );
492492 }
493493
494- //If $skipCache, or skipCache(), or the key does not exist then call the API
495- if ($ skipCache || $ this ->skipCache () || !$ this ->cache ->has ($ cacheKey )) {
496- try {
497- $ response = $ this ->call ($ method , $ uri , $ body );
498- $ this ->cache ->set ($ cacheKey , $ response , $ ttl );
499- } catch (FlagsmithAPIError $ e ) {
500- if (
501- !$ this ->useCacheAsFailover ||
502- !$ this ->cache ->has ($ cacheKey )
503- ) {
504- throw $ e ;
505- }
494+ if (!$ skipCache && !$ this ->skipCache ()) {
495+ $ cachedCall = $ this ->cache ->get ($ cacheKey );
496+ if (\is_array ($ cachedCall ) || \is_object ($ cachedCall )) {
497+ return $ cachedCall ;
506498 }
507499 }
508500
509- return $ this ->cache ->get ($ cacheKey );
501+ try {
502+ $ response = $ this ->call ($ method , $ uri , $ body );
503+ $ this ->cache ->set ($ cacheKey , $ response , $ ttl );
504+
505+ return $ response ;
506+ } catch (FlagsmithAPIError $ e ) {
507+ if ($ this ->useCacheAsFailover ) {
508+ $ cachedCall = $ this ->cache ->get ($ cacheKey );
509+ if (\is_array ($ cachedCall ) || \is_object ($ cachedCall )) {
510+ return $ cachedCall ;
511+ }
512+ }
513+
514+ throw $ e ;
515+ }
510516 }
511517
512518 /**
You can’t perform that action at this time.
0 commit comments