Skip to content

Commit

Permalink
renamed Cache::$ttl to Cache::$defaultDuration
Browse files Browse the repository at this point in the history
better naming as discussed in yiisoft#12990
  • Loading branch information
cebe committed Nov 15, 2016
1 parent f76f0cf commit 059a80b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Yii Framework 2 Change Log
- Bug #12904: Fixed lowercase table name in migrations (zlakomanoff)
- Bug #12939: Hard coded table names for MSSQL in RBAC migration (arogachev)
- Bug #12974: Fixed incorrect order of migrations history in case `yii\console\controllers\MigrateController::$migrationNamespaces` is in use (evgen-d, klimov-paul)
- Enh #6809: Added `\yii\caching\Cache::$ttl` property, allowing to set custom default cache duration (sdkiller)
- Enh #6809: Added `\yii\caching\Cache::$defaultDuration` property, allowing to set custom default cache duration (sdkiller)
- Enh #11037: `yii.js` and `yii.validation.js` use `Regexp.test()` instead of `String.match()` (arogachev, nkovacs)
- Enh #11756: Added type mapping for `varbinary` data type in MySQL DBMS (silverfire)
- Enh #11929: Changed `type` column type from `int` to `smallInt` in RBAC migrations (silverfire)
Expand Down
7 changes: 4 additions & 3 deletions framework/caching/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ abstract class Cache extends Component implements \ArrayAccess
*/
public $serializer;
/**
* @var integer default duration in seconds before the cache will expire. Default value is 0, meaning infinity.
* @var integer default duration in seconds before a cache entry will expire. Default value is 0, meaning infinity.
* This value is used by [[set()]] if the duration is not explicitly given.
* @since 2.0.11
*/
public $ttl = 0;
public $defaultDuration = 0;


/**
Expand Down Expand Up @@ -217,7 +218,7 @@ public function multiGet($keys)
public function set($key, $value, $duration = null, $dependency = null)
{
if ($duration === null) {
$duration = $this->ttl;
$duration = $this->defaultDuration;
}

if ($dependency !== null && $this->serializer !== false) {
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/caching/CacheTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function testDefaultTtl()
{
$cache = $this->getCacheInstance();

$this->assertSame(0, $cache->ttl);
$this->assertSame(0, $cache->defaultDuration);
}

public function testExpire()
Expand Down

0 comments on commit 059a80b

Please sign in to comment.