Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
fad01127
Commit
fad01127
authored
May 01, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added missing init() method to Cache class
parent
3b4abfff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
8 deletions
+24
-8
Cache.php
framework/caching/Cache.php
+12
-0
RedisCache.php
framework/caching/RedisCache.php
+2
-8
CacheTest.php
tests/unit/framework/caching/CacheTest.php
+10
-0
No files found.
framework/caching/Cache.php
View file @
fad01127
...
...
@@ -71,6 +71,18 @@ abstract class Cache extends Component implements \ArrayAccess
/**
* 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
=
\Yii
::
$app
->
id
;
}
}
/**
* Builds a normalized cache key from a given key.
*
* The generated key contains letters and digits only, and its length is no more than 32.
...
...
framework/caching/RedisCache.php
View file @
fad01127
...
...
@@ -20,8 +20,8 @@ use yii\db\redis\Connection;
* When the server needs authentication, you can set the [[password]] property to
* authenticate with the server after connect.
*
* See [[Cache]] for common cache operations that RedisCache supports.
* Different from the description in [[Cache]] RedisCache allows the expire parameter of
* See [[Cache]]
manual
for common cache operations that RedisCache supports.
* Different from the description in [[Cache]]
,
RedisCache allows the expire parameter of
* [[set]] and [[add]] to be a floating point number, so you may specify the time in milliseconds.
*
* To use RedisCache as the cache application component, configure the application as follows,
...
...
@@ -39,12 +39,6 @@ use yii\db\redis\Connection;
* )
* ~~~
*
* In the above, two memcache servers are used: server1 and server2. You can configure more properties of
* each server, such as `persistent`, `weight`, `timeout`. Please see [[MemCacheServer]] for available options.
*
* @property \Memcache|\Memcached $memCache The memcache instance (or memcached if [[useMemcached]] is true) used by this component.
* @property MemCacheServer[] $servers List of memcache server configurations.
*
* @author Carsten Brandt <mail@cebe.cc>
* @since 2.0
*/
...
...
tests/unit/framework/caching/CacheTest.php
View file @
fad01127
...
...
@@ -29,6 +29,16 @@ abstract class CacheTest extends TestCase
return
$cache
;
}
/**
* default value of cache prefix is application id
*/
public
function
testKeyPrefix
()
{
$cache
=
$this
->
getCacheInstance
();
$this
->
assertNotNull
(
\Yii
::
$app
->
id
);
$this
->
assertEquals
(
\Yii
::
$app
->
id
,
$cache
->
keyPrefix
);
}
public
function
testSet
()
{
$cache
=
$this
->
getCacheInstance
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment