-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from TheDragonCode/2.x
Added the ability to use a TTL contract
- Loading branch information
Showing
8 changed files
with
184 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Fixtures\Ttl; | ||
|
||
use Carbon\Carbon; | ||
use DragonCode\Contracts\Cache\Ttl; | ||
|
||
class AsCarbon implements Ttl | ||
{ | ||
protected $value; | ||
|
||
public function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
public function cacheTtl(): Carbon | ||
{ | ||
return $this->value === 'foo' | ||
? Carbon::now()->addHour() | ||
: Carbon::now()->addHours(2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Fixtures\Ttl; | ||
|
||
use DateTime; | ||
use DateTimeInterface; | ||
use DragonCode\Contracts\Cache\Ttl; | ||
|
||
class AsDateTime implements Ttl | ||
{ | ||
protected $value; | ||
|
||
public function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
public function cacheTtl(): DateTimeInterface | ||
{ | ||
return $this->value === 'foo' | ||
? new DateTime('+1 hour') | ||
: new DateTime('+2 hour'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Fixtures\Ttl; | ||
|
||
use DragonCode\Contracts\Cache\Ttl; | ||
|
||
class AsInteger implements Ttl | ||
{ | ||
protected $value; | ||
|
||
public function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
public function cacheTtl(): int | ||
{ | ||
return $this->value === 'foo' ? 10 : 20; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Fixtures\Ttl; | ||
|
||
use DragonCode\Contracts\Cache\Ttl; | ||
|
||
class AsString implements Ttl | ||
{ | ||
protected $value; | ||
|
||
public function __construct(string $value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
public function cacheTtl(): string | ||
{ | ||
return $this->value === 'foo' ? '10' : '20'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters