-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
steffen.brand
committed
Feb 23, 2017
1 parent
d4217a7
commit 89ef727
Showing
7 changed files
with
140 additions
and
57 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,98 @@ | ||
<?php | ||
|
||
namespace SteffenBrand\CurrCurr\Model; | ||
|
||
use Psr\SimpleCache\CacheInterface; | ||
|
||
class CacheConfig { | ||
|
||
/** | ||
* @const int | ||
*/ | ||
const CACHE_UNTIL_MIDNIGHT = -1; | ||
|
||
/** | ||
* @const string | ||
*/ | ||
const DEFAULT_CACHE_KEY = 'curr-curr-cache'; | ||
|
||
/** | ||
* @var CacheInterface | ||
*/ | ||
private $cache; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $cacheTimeInSeconds; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $cacheKey; | ||
|
||
/** | ||
* CacheConfig constructor. | ||
* | ||
* @param CacheInterface $cache PSR-16 compliant CacheInterface implementation | ||
* @param int $cacheTimeInSeconds TTL in seconds | ||
* @param string $cacheKey Key to use for caching | ||
*/ | ||
public function __construct(CacheInterface $cache = null, | ||
$cacheTimeInSeconds = self::CACHE_UNTIL_MIDNIGHT, | ||
$cacheKey = self::DEFAULT_CACHE_KEY) | ||
{ | ||
$this->cache = $cache; | ||
$this->cacheTimeInSeconds = $cacheTimeInSeconds; | ||
$this->cacheKey = $cacheKey; | ||
} | ||
|
||
/** | ||
* @return CacheInterface | ||
*/ | ||
public function getCache(): CacheInterface | ||
{ | ||
return $this->cache; | ||
} | ||
|
||
/** | ||
* @param CacheInterface $cache | ||
*/ | ||
public function setCache(CacheInterface $cache) | ||
{ | ||
$this->cache = $cache; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getCacheTimeInSeconds(): int | ||
{ | ||
return $this->cacheTimeInSeconds; | ||
} | ||
|
||
/** | ||
* @param int $cacheTimeInSeconds | ||
*/ | ||
public function setCacheTimeInSeconds(int $cacheTimeInSeconds) | ||
{ | ||
$this->cacheTimeInSeconds = $cacheTimeInSeconds; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getCacheKey(): string | ||
{ | ||
return $this->cacheKey; | ||
} | ||
|
||
/** | ||
* @param string $cacheKey | ||
*/ | ||
public function setCacheKey(string $cacheKey) | ||
{ | ||
$this->cacheKey = $cacheKey; | ||
} | ||
|
||
} |
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