Skip to content

have flush return the count of successful invalidation requests #47

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

Merged
merged 1 commit into from
Mar 11, 2014

Conversation

dbu
Copy link
Contributor

@dbu dbu commented Mar 9, 2014

@@ -106,11 +106,12 @@ public function flush()
{
$queue = $this->queue;
if (0 === count($queue)) {
return;
return 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this is no real BC break as we did not respect the fluent interface we promised in the interface...

@dbu
Copy link
Contributor Author

dbu commented Mar 9, 2014

hm, travis fails but i think this reveals we have an issue here. failing because something was not cached makes no sense - the application can't know if the document is cached or not.

do we want to ignore 404 errors or do we want to change our propsed varnish configuration? probably a 204 No Content response code would make most sense.

->purge('/a')
->flush()
);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be a functional rather than a unit test?

@ddeboer
Copy link
Member

ddeboer commented Mar 9, 2014

probably a 204 No Content response code would make most sense.

Yeah, please change that in purge.vcl and the docs. I can’t really think of a use case where the application needs to know whether the content that should be invalidated was cached or not.

@@ -167,7 +169,10 @@ protected function sendRequests(array $requests)
$this->client->send($allRequests);
} catch (MultiTransferException $e) {
$this->handleException($e);
$count = $e->getSuccessfulRequests();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conflates the two meanings of “number of requests”: now $count no longer means “number of requests sent to each proxy” but “number of (successful) requests sent in total to all proxies together”.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch, you are right. hm, i guess this will become very difficult to handle. what should we do? return -1 if there is at least one success, to indicate the number could not be determined due to a partial error? we could divide by the number of backends but that is a wild guess...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or simply change the statistic to mean “total number of (successful) requests”? Would that make it less useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying to build a test for this helped - it just can't matter, as handleException throws the retransformed exception and we never return a count for a (partially) failed invalidation action.

}
}

sub vcl_miss {
if (req.request == "PURGE") {
purge;
error 404 "Not in cache";
error 204 "Purged (Not in cache)";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like this its still debuggable what is going on.

@dbu
Copy link
Contributor Author

dbu commented Mar 9, 2014

okay, updated. i think now it makes sense. we probably want to handle the exceptions in the symfony console listener and print some information that cache invalidation did not work out. (if no invalidation was sent, i would expect to have no exception ever, so that should be correct to report when something went wrong)

@@ -168,6 +170,8 @@ protected function sendRequests(array $requests)
} catch (MultiTransferException $e) {
$this->handleException($e);
}

return $count;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for setting a variable anymore. Just return count($requests) directly.

@ddeboer
Copy link
Member

ddeboer commented Mar 9, 2014

One minor detail, looks fine otherwise.

@dbu
Copy link
Contributor Author

dbu commented Mar 9, 2014

removed the $count variable.

@@ -6,6 +6,7 @@
use FOS\HttpCache\Invalidation\Varnish;
use Guzzle\Http\Client;
use Guzzle\Http\Exception\CurlException;
use Guzzle\Http\Exception\MultiTransferException;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is not being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. updated.

@dbu
Copy link
Contributor Author

dbu commented Mar 11, 2014

simplified and squashed.

ddeboer added a commit that referenced this pull request Mar 11, 2014
have flush return the count of successful invalidation requests
@ddeboer ddeboer merged commit 6cbd607 into master Mar 11, 2014
@ddeboer
Copy link
Member

ddeboer commented Mar 11, 2014

Thanks!

@ddeboer ddeboer deleted the flush-return-count branch March 11, 2014 09:49
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.

2 participants