Commit 5439ab78 by Qiang Xue

Changed the default value of `Cache::keyPrefix` to be null.

parent 5c5fcd6e
...@@ -63,7 +63,7 @@ Yii Framework 2 Change Log ...@@ -63,7 +63,7 @@ Yii Framework 2 Change Log
- Chg: `yii\grid\DataColumn::getDataCellValue()` visibility is now `public` to allow accessing the value from a GridView directly (cebe) - Chg: `yii\grid\DataColumn::getDataCellValue()` visibility is now `public` to allow accessing the value from a GridView directly (cebe)
- Chg: `yii\data\ActiveDataProvider::$query` will not be modified directly with pagination and sorting anymore so it will be reuseable (cebe) - Chg: `yii\data\ActiveDataProvider::$query` will not be modified directly with pagination and sorting anymore so it will be reuseable (cebe)
- Chg: Removed `yii\rest\ActiveController::$transactional` property and connected functionality (samdark) - Chg: Removed `yii\rest\ActiveController::$transactional` property and connected functionality (samdark)
- Chg: Changed the default value of the `keyPrefix` property of cache components to be null (qiangxue)
2.0.0-beta April 13, 2014 2.0.0-beta April 13, 2014
------------------------- -------------------------
......
...@@ -29,3 +29,7 @@ Upgrade from Yii 2.0 Beta ...@@ -29,3 +29,7 @@ Upgrade from Yii 2.0 Beta
`yii\filters\auth\HttpBearerAuth` authentication method, the value of this parameter will be `yii\filters\auth\HttpBearerAuth` authentication method, the value of this parameter will be
`yii\filters\auth\HttpBearerAuth`. This allows you to differentiate access tokens taken by `yii\filters\auth\HttpBearerAuth`. This allows you to differentiate access tokens taken by
different authentication methods. different authentication methods.
* If you are sharing the same cache across different applications, you should configure
the `keyPrefix` property of the cache component to use some unique string.
Previously, this property was automatically assigned with a unique string.
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace yii\caching; namespace yii\caching;
use Yii;
use yii\base\Component; use yii\base\Component;
use yii\helpers\StringHelper; use yii\helpers\StringHelper;
...@@ -52,10 +51,9 @@ use yii\helpers\StringHelper; ...@@ -52,10 +51,9 @@ use yii\helpers\StringHelper;
abstract class Cache extends Component implements \ArrayAccess abstract class Cache extends Component implements \ArrayAccess
{ {
/** /**
* @var string a string prefixed to every cache key so that it is unique. If not set, * @var string a string prefixed to every cache key so that it is unique globally in the whole cache storage.
* it will use a prefix generated from [[\yii\base\Application::id]]. You may set this property to be an empty string * It is recommended that you set a unique cache key prefix for each application if the same cache
* if you don't want to use key prefix. It is recommended that you explicitly set this property to some * storage is being used by different applications.
* static value if the cached data needs to be shared among multiple applications.
* *
* To ensure interoperability, only alphanumeric characters should be used. * To ensure interoperability, only alphanumeric characters should be used.
*/ */
...@@ -71,17 +69,6 @@ abstract class Cache extends Component implements \ArrayAccess ...@@ -71,17 +69,6 @@ abstract class Cache extends Component implements \ArrayAccess
*/ */
public $serializer; public $serializer;
/**
* Initializes the application component.
* This method overrides the parent implementation by setting default cache key prefix.
*/
public function init()
{
parent::init();
if ($this->keyPrefix === null) {
$this->keyPrefix = substr(md5(Yii::$app->id), 0, 5);
}
}
/** /**
* Builds a normalized cache key from a given key. * Builds a normalized cache key from a given key.
......
...@@ -58,16 +58,6 @@ abstract class CacheTestCase extends TestCase ...@@ -58,16 +58,6 @@ abstract class CacheTestCase extends TestCase
return $cache; return $cache;
} }
/**
* default value of cache prefix is application id
*/
public function testKeyPrefix()
{
$cache = $this->getCacheInstance();
$this->assertNotNull(\Yii::$app->id);
$this->assertNotNull($cache->keyPrefix);
}
public function testSet() public function testSet()
{ {
$cache = $this->getCacheInstance(); $cache = $this->getCacheInstance();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment