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
d03b2add
Commit
d03b2add
authored
Jan 22, 2014
by
Daniel Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Condenses changelog notes to 1 line (#2103)
parent
087943cd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
8 deletions
+119
-8
CHANGELOG.md
framework/CHANGELOG.md
+1
-8
BypassPhpCacheSession.php
framework/web/BypassPhpCacheSession.php
+118
-0
No files found.
framework/CHANGELOG.md
View file @
d03b2add
...
@@ -4,14 +4,7 @@ Yii Framework 2 Change Log
...
@@ -4,14 +4,7 @@ Yii Framework 2 Change Log
2.
0.0 beta under development
2.
0.0 beta under development
----------------------------
----------------------------
-
Enh #2103: Added docblock description and link to HTTP spec for BadRequestHttpException (danschmidt5189)
-
Enh #2103: Adds docblock descriptions and links to HTTP specs for new HTTP exception classes (danschmidt5189)
-
Enh #2103: Added docblock description and link to HTTP spec for UnauthorizedHttpException (danschmidt5189)
-
Enh #2103: Added docblock description and link to HTTP spec for ForbiddenHttpException (danschmidt5189)
-
Enh #2103: Added docblock description and link to HTTP spec for NotAcceptableHttpException (danschmidt5189)
-
Enh #2103: Added link to HTTP spec for ConflictHttpException (danschmidt5189)
-
Enh #2103: Added docblock description and link to HTTP spec for GoneHttpException (danschmidt5189)
-
Enh #2103: Added docblock description and link to HTTP spec for UnsupportedMediaTypeHttpException (danschmidt5189)
-
Enh #2103: Added docblock description and link to HTTP spec for TooManyRequestsHttpException (danschmidt5189)
-
Enh #2103: Renames AccessDeniedHttpException to ForbiddenHttpException (danschmidt5189)
-
Enh #2103: Renames AccessDeniedHttpException to ForbiddenHttpException (danschmidt5189)
-
Bug #1265: AssetController does not override 'js' and 'css' for compressed bundles (klimov-paul)
-
Bug #1265: AssetController does not override 'js' and 'css' for compressed bundles (klimov-paul)
-
Bug #1326: The
`visible`
setting for
`DetailView`
doesn't work as expected (qiangxue)
-
Bug #1326: The
`visible`
setting for
`DetailView`
doesn't work as expected (qiangxue)
...
...
framework/web/BypassPhpCacheSession.php
0 → 100644
View file @
d03b2add
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\web
;
use
Yii
;
use
yii\caching\Cache
;
use
yii\base\InvalidConfigException
;
/**
* CacheSession implements a session component using cache as storage medium.
*
* The cache being used can be any cache application component.
* The ID of the cache application component is specified via [[cache]], which defaults to 'cache'.
*
* Beware, by definition cache storage are volatile, which means the data stored on them
* may be swapped out and get lost. Therefore, you must make sure the cache used by this component
* is NOT volatile. If you want to use database as storage medium, [[DbSession]] is a better choice.
*
* The following example shows how you can configure the application to use CacheSession:
* Add the following to your application config under `components`:
*
* ~~~
* 'session' => [
* 'class' => 'yii\web\CacheSession',
* // 'cache' => 'mycache',
* ]
* ~~~
*
* @property boolean $useCustomStorage Whether to use custom storage. This property is read-only.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
CacheSession
extends
Session
{
/**
* @var Cache|string the cache object or the application component ID of the cache object.
* The session data will be stored using this cache object.
*
* After the CacheSession object is created, if you want to change this property,
* you should only assign it with a cache object.
*/
public
$cache
=
'cache'
;
/**
* Initializes the application component.
*/
public
function
init
()
{
if
(
is_string
(
$this
->
cache
))
{
$this
->
cache
=
Yii
::
$app
->
getComponent
(
$this
->
cache
);
}
if
(
!
$this
->
cache
instanceof
Cache
)
{
throw
new
InvalidConfigException
(
'CacheSession::cache must refer to the application component ID of a cache object.'
);
}
parent
::
init
();
}
/**
* Returns a value indicating whether to use custom session storage.
* This method overrides the parent implementation and always returns true.
* @return boolean whether to use custom storage.
*/
public
function
getUseCustomStorage
()
{
return
true
;
}
/**
* Session read handler.
* Do not call this method directly.
* @param string $id session ID
* @return string the session data
*/
public
function
readSession
(
$id
)
{
$data
=
$this
->
cache
->
get
(
$this
->
calculateKey
(
$id
));
return
$data
===
false
?
''
:
$data
;
}
/**
* Session write handler.
* Do not call this method directly.
* @param string $id session ID
* @param string $data session data
* @return boolean whether session write is successful
*/
public
function
writeSession
(
$id
,
$data
)
{
return
$this
->
cache
->
set
(
$this
->
calculateKey
(
$id
),
$data
,
$this
->
getTimeout
());
}
/**
* Session destroy handler.
* Do not call this method directly.
* @param string $id session ID
* @return boolean whether session is destroyed successfully
*/
public
function
destroySession
(
$id
)
{
return
$this
->
cache
->
delete
(
$this
->
calculateKey
(
$id
));
}
/**
* Generates a unique key used for storing session data in cache.
* @param string $id session variable name
* @return mixed a safe cache key associated with the session variable name
*/
protected
function
calculateKey
(
$id
)
{
return
[
__CLASS__
,
$id
];
}
}
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