Skip to content

Commit 7e7f234

Browse files
committed
wip
1 parent 65bfad0 commit 7e7f234

File tree

5 files changed

+49
-12
lines changed

5 files changed

+49
-12
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use Meema\CloudFront\Facades\CloudFront;
2222
// run any of the following CloudFront methods:
2323
$client = CloudFront::getClient(); // exposes the AWS CloudFront client
2424

25-
$items = ['/some-path.jpg', '/another/path.png'];
26-
$result = CloudFront::invalidate($items, string $distributionId = null);
25+
$paths = ['/some-path.jpg', '/another/path.png'];
26+
$result = CloudFront::invalidate($paths, string $distributionId = null);
2727

2828
// invalidates everything, which is the equivalent to a item path of `/*`.
2929
$result = CloudFront::reset();

src/CloudFront.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ public function getClient(): CloudFrontClient
4545
/**
4646
* Bust an item/s in CloudFront's cache.
4747
*
48-
* @param array|string $items
48+
* @param array|string $paths
4949
* @param string|null $distributionId
5050
* @return \Aws\Result
5151
*/
52-
public function invalidate($items, string $distributionId = null)
52+
public function invalidate($paths, string $distributionId = null)
5353
{
54-
if (is_string($items)) {
55-
$arr[] = $items;
56-
$items = $arr;
54+
if (is_string($paths)) {
55+
$arr[] = $paths;
56+
$paths = $arr;
5757
}
5858

5959
return $this->client->createInvalidation([
@@ -63,8 +63,8 @@ public function invalidate($items, string $distributionId = null)
6363
// You must provide a new caller reference value and other new information in the request for CloudFront to create a new invalidation request.
6464
'CallerReference' => microtime(true),
6565
'Paths' => [
66-
'Items' => $items,
67-
'Quantity' => count($items),
66+
'Items' => $paths,
67+
'Quantity' => count($paths),
6868
],
6969
],
7070
]);

src/Contracts/CloudFront.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ interface CloudFront
77
/**
88
* Delete items in your CloudFront cache .
99
*
10-
* @param array|string $items
10+
* @param array|string $paths
1111
* @param string|null $distributionId
1212
* @return \Aws\Result
1313
*/
14-
public function invalidate($items, string $distributionId = null);
14+
public function invalidate($paths, string $distributionId = null);
1515

1616
/**
1717
* Delete everything in your CloudFront cache .

src/Facades/CloudFront.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/**
88
* @method static \Aws\CloudFront\CloudFrontClient getClient()
9-
* @method static \Aws\Result invalidate(array|string $items, string $distributionId = null)
9+
* @method static \Aws\Result invalidate(array|string $paths, string $distributionId = null)
1010
* @method static \Aws\Result reset(string $distributionId = null)
1111
* @method static string getInvalidation(string $invalidationId, string $distributionId = null)
1212
* @method static array listInvalidations(string $distributionId = null)

src/Jobs/InvalidateCache.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Meema\CloudFront\Jobs;
4+
5+
use Illuminate\Bus\Queueable;
6+
use Illuminate\Contracts\Queue\ShouldQueue;
7+
use Illuminate\Foundation\Bus\Dispatchable;
8+
use Illuminate\Queue\InteractsWithQueue;
9+
use Illuminate\Queue\SerializesModels;
10+
use Meema\CloudFront\Facades\CloudFront;
11+
12+
class InvalidateCache implements ShouldQueue
13+
{
14+
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
15+
16+
private $paths;
17+
18+
/**
19+
* Create a new job instance.
20+
*
21+
* @param string|array $paths
22+
*/
23+
public function __construct($paths)
24+
{
25+
$this->paths = $paths;
26+
}
27+
28+
/**
29+
* Execute the job.
30+
*
31+
* @return void
32+
*/
33+
public function handle()
34+
{
35+
CloudFront::invalidate($this->paths);
36+
}
37+
}

0 commit comments

Comments
 (0)