Skip to content

Commit

Permalink
Merge pull request #51 from FriendsOfSymfony/naming
Browse files Browse the repository at this point in the history
Improve naming (fix #50)
  • Loading branch information
dbu committed Apr 4, 2014
2 parents 58fa3ae + ed626d3 commit e0a5473
Show file tree
Hide file tree
Showing 16 changed files with 71 additions and 71 deletions.
6 changes: 3 additions & 3 deletions doc/cache-invalidator.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ an [adapter](http://en.wikipedia.org/wiki/Adapter_pattern):

```php
use FOS\HttpCache\CacheInvalidator;
use FOS\HttpCache\Invalidation;
use FOS\HttpCache\ProxyClient;

$client = new Invalidation\Varnish();
$client = new ProxyClient\Varnish();
// or
$client = new Invalidation\Nginx();
$client = new ProxyClient\Nginx();

$cacheInvalidator = new CacheInvalidator($client);
```
Expand Down
10 changes: 5 additions & 5 deletions doc/proxy-clients.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ You can use the caching proxy clients either wrapped by the cache invalidator
(recommended), or directly for low-level access to invalidation functionality.

* [Setup](#setup)
* [CacheProxyInterface](#cacheproxyinterface)
* [ProxyClientInterface](#cacheproxyinterface)
* [Purge](#purge)
* [Refresh](#refresh)
* [Ban](#ban)
Expand All @@ -20,16 +20,16 @@ You should set up at least one caching proxy client:

Then continue here to find out how to use the proxy clients.

CacheProxyInterface
ProxyClientInterface
-------------------

Each client is an implementation of [CacheProxyInterface](../src/Invalidation/CacheProxyInterface.php).
Each client is an implementation of [ProxyClientInterface](../src/ProxyClient/ProxyClientInterface.php).
All other interfaces, `PurgeInterface`, `RefreshInterface` and `BanInterface`
extend this `CacheProxyInterface`. So each client implements at least one of
extend this `ProxyClientInterface`. So each client implements at least one of
the three [invalidation methods](invalidation-introduction.md#invalidation-methods),
depending on the caching proxy’s abilities.

The `CacheProxyInterface` has one method: `flush()`. After collecting
The `ProxyClientInterface` has one method: `flush()`. After collecting
invalidation requests, `flush()` needs to be called to actually send the
requests to the caching proxy. This is on purpose: this way, we can send
all requests together, reducing the performance impact of sending invalidation
Expand Down
2 changes: 1 addition & 1 deletion doc/varnish-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ that you want to send invalidation requests to. Make sure to include the port
Varnish runs on if it is not port 80.

```php
use FOS\HttpCache\Invalidation\Varnish;
use FOS\HttpCache\ProxyClient\Varnish;

$servers = array('10.0.0.1', '10.0.0.2:6081'); // Port 80 assumed for 10.0.0.1
$varnish = new Varnish($servers);
Expand Down
36 changes: 18 additions & 18 deletions src/CacheInvalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
use FOS\HttpCache\Exception\InvalidArgumentException;
use FOS\HttpCache\Exception\ProxyResponseException;
use FOS\HttpCache\Exception\ProxyUnreachableException;
use FOS\HttpCache\Exception\UnsupportedInvalidationMethodException;
use FOS\HttpCache\Invalidation\CacheProxyInterface;
use FOS\HttpCache\Invalidation\Method\BanInterface;
use FOS\HttpCache\Invalidation\Method\PurgeInterface;
use FOS\HttpCache\Invalidation\Method\RefreshInterface;
use FOS\HttpCache\Exception\UnsupportedProxyOperationException;
use FOS\HttpCache\ProxyClient\ProxyClientInterface;
use FOS\HttpCache\ProxyClient\Invalidation\BanInterface;
use FOS\HttpCache\ProxyClient\Invalidation\PurgeInterface;
use FOS\HttpCache\ProxyClient\Invalidation\RefreshInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand Down Expand Up @@ -38,7 +38,7 @@ class CacheInvalidator
const INVALIDATE = 'invalidate';

/**
* @var CacheProxyInterface
* @var ProxyClientInterface
*/
protected $cache;

Expand All @@ -55,9 +55,9 @@ class CacheInvalidator
/**
* Constructor
*
* @param CacheProxyInterface $cache HTTP cache
* @param ProxyClientInterface $cache HTTP cache
*/
public function __construct(CacheProxyInterface $cache)
public function __construct(ProxyClientInterface $cache)
{
$this->cache = $cache;
}
Expand Down Expand Up @@ -159,14 +159,14 @@ public function getTagsHeader()
*
* @param string $path Path or URL
*
* @throws UnsupportedInvalidationMethodException
* @throws UnsupportedProxyOperationException
*
* @return $this
*/
public function invalidatePath($path)
{
if (!$this->cache instanceof PurgeInterface) {
throw UnsupportedInvalidationMethodException::cacheDoesNotImplement('PURGE');
throw UnsupportedProxyOperationException::cacheDoesNotImplement('PURGE');
}

$this->cache->purge($path);
Expand All @@ -182,14 +182,14 @@ public function invalidatePath($path)
*
* @see RefreshInterface::refresh()
*
* @throws UnsupportedInvalidationMethodException
* @throws UnsupportedProxyOperationException
*
* @return $this
*/
public function refreshPath($path, array $headers = array())
{
if (!$this->cache instanceof RefreshInterface) {
throw UnsupportedInvalidationMethodException::cacheDoesNotImplement('REFRESH');
throw UnsupportedProxyOperationException::cacheDoesNotImplement('REFRESH');
}

$this->cache->refresh($path, $headers);
Expand All @@ -207,14 +207,14 @@ public function refreshPath($path, array $headers = array())
*
* @param array $headers HTTP headers that path must match to be banned.
*
* @throws UnsupportedInvalidationMethodException If HTTP cache does not support BAN requests
* @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests
*
* @return $this
*/
public function invalidate(array $headers)
{
if (!$this->cache instanceof BanInterface) {
throw UnsupportedInvalidationMethodException::cacheDoesNotImplement('BAN');
throw UnsupportedProxyOperationException::cacheDoesNotImplement('BAN');
}

$this->cache->ban($headers);
Expand All @@ -240,14 +240,14 @@ public function invalidate(array $headers)
* @param array|string $hosts Regular expression of a host name or list of
* exact host names to limit banning.
*
* @throws UnsupportedInvalidationMethodException If HTTP cache does not support BAN requests
* @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests
*
* @return $this
*/
public function invalidateRegex($path, $contentType = null, $hosts = null)
{
if (!$this->cache instanceof BanInterface) {
throw UnsupportedInvalidationMethodException::cacheDoesNotImplement('BAN');
throw UnsupportedProxyOperationException::cacheDoesNotImplement('BAN');
}

$this->cache->banPath($path, $contentType, $hosts);
Expand All @@ -263,14 +263,14 @@ public function invalidateRegex($path, $contentType = null, $hosts = null)
*
* @param array $tags Cache tags
*
* @throws UnsupportedInvalidationMethodException If HTTP cache does not support BAN requests
* @throws UnsupportedProxyOperationException If HTTP cache does not support BAN requests
*
* @return $this
*/
public function invalidateTags(array $tags)
{
if (!$this->cache instanceof BanInterface) {
throw UnsupportedInvalidationMethodException::cacheDoesNotImplement('BAN');
throw UnsupportedProxyOperationException::cacheDoesNotImplement('BAN');
}

$headers = array($this->getTagsHeader() => '('.implode('|', $tags).')(,.+)?$');
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/ExceptionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/**
* A collection of exceptions that might occur during the flush operation of a
* CacheProxyInterface implementation
* ProxyClientInterface implementation
*/
class ExceptionCollection extends \Exception implements \IteratorAggregate, \Countable, HttpCacheExceptionInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* Thrown when the CacheInvalidator is asked for an operation the underlying
* cache proxy does not support.
*/
class UnsupportedInvalidationMethodException extends \RuntimeException implements HttpCacheExceptionInterface
class UnsupportedProxyOperationException extends \RuntimeException implements HttpCacheExceptionInterface
{
/**
* @param string $method Name of the HTTP method that would be required.
*
* @return UnsupportedInvalidationMethodException
* @return UnsupportedProxyOperationException
*/
public static function cacheDoesNotImplement($method)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace FOS\HttpCache\Invalidation;
namespace FOS\HttpCache\ProxyClient;

use FOS\HttpCache\Exception\ExceptionCollection;
use FOS\HttpCache\Exception\InvalidUrlException;
Expand All @@ -18,7 +18,7 @@
*
* @author David de Boer <[email protected]>
*/
abstract class AbstractCacheProxy implements CacheProxyInterface
abstract class AbstractProxyClient implements ProxyClientInterface
{
/**
* IP addresses/hostnames of all caching proxy servers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace FOS\HttpCache\Invalidation\Method;
namespace FOS\HttpCache\ProxyClient\Invalidation;

use FOS\HttpCache\Invalidation\CacheProxyInterface;
use FOS\HttpCache\ProxyClient\ProxyClientInterface;

/**
* An HTTP cache that supports invalidation by banning, that is, removing
* objects from the cache that match a regular expression
*/
interface BanInterface extends CacheProxyInterface
interface BanInterface extends ProxyClientInterface
{
const REGEX_MATCH_ALL = '.*';
const CONTENT_TYPE_ALL = self::REGEX_MATCH_ALL;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace FOS\HttpCache\Invalidation\Method;
namespace FOS\HttpCache\ProxyClient\Invalidation;

use FOS\HttpCache\Invalidation\CacheProxyInterface;
use FOS\HttpCache\ProxyClient\ProxyClientInterface;

/**
* An HTTP cache that supports invalidation by purging, that is, removing one
Expand All @@ -11,7 +11,7 @@
* Implementations should be configurable with a default host to be able to
* handle purge calls that do not contain a full URL but only a path.
*/
interface PurgeInterface extends CacheProxyInterface
interface PurgeInterface extends ProxyClientInterface
{
/**
* Purge a URL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace FOS\HttpCache\Invalidation\Method;
namespace FOS\HttpCache\ProxyClient\Invalidation;

use FOS\HttpCache\Invalidation\CacheProxyInterface;
use FOS\HttpCache\ProxyClient\ProxyClientInterface;

/**
* An HTTP cache that supports invalidation by refresh requests that force a
Expand All @@ -11,7 +11,7 @@
* Implementations should be configurable with a default host to be able to
* handle refresh calls that do not contain a full URL but only a path.
*/
interface RefreshInterface extends CacheProxyInterface
interface RefreshInterface extends ProxyClientInterface
{
/**
* Refresh a URL.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace FOS\HttpCache\Invalidation;
namespace FOS\HttpCache\ProxyClient;

use FOS\HttpCache\Exception\ExceptionCollection;

/**
* An HTTP caching reverse proxy.
* An HTTP caching reverse proxy client
*
* Implementations should implement at least one of the Method interfaces.
* Implementations should implement at least one of the Invalidation interfaces.
*/
interface CacheProxyInterface
interface ProxyClientInterface
{
/**
* Send all pending invalidation requests.
Expand Down
10 changes: 5 additions & 5 deletions src/Invalidation/Varnish.php → src/ProxyClient/Varnish.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php

namespace FOS\HttpCache\Invalidation;
namespace FOS\HttpCache\ProxyClient;

use FOS\HttpCache\Exception\InvalidArgumentException;
use FOS\HttpCache\Exception\MissingHostException;
use FOS\HttpCache\Invalidation\Method\BanInterface;
use FOS\HttpCache\Invalidation\Method\PurgeInterface;
use FOS\HttpCache\Invalidation\Method\RefreshInterface;
use FOS\HttpCache\ProxyClient\Invalidation\BanInterface;
use FOS\HttpCache\ProxyClient\Invalidation\PurgeInterface;
use FOS\HttpCache\ProxyClient\Invalidation\RefreshInterface;

/**
* Varnish HTTP cache invalidator.
*
* @author David de Boer <[email protected]>
*/
class Varnish extends AbstractCacheProxy implements BanInterface, PurgeInterface, RefreshInterface
class Varnish extends AbstractProxyClient implements BanInterface, PurgeInterface, RefreshInterface
{
const HTTP_METHOD_BAN = 'BAN';
const HTTP_METHOD_PURGE = 'PURGE';
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/VarnishTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace FOS\HttpCache\Tests\Functional;

use FOS\HttpCache\Invalidation\Varnish;
use FOS\HttpCache\ProxyClient\Varnish;
use FOS\HttpCache\Tests\VarnishTestCase;

/**
Expand Down
Loading

0 comments on commit e0a5473

Please sign in to comment.