diff --git a/framework/web/BypassPhpCacheSession.php b/framework/web/BypassPhpCacheSession.php deleted file mode 100644 index 7b4a98d407..0000000000 --- a/framework/web/BypassPhpCacheSession.php +++ /dev/null @@ -1,118 +0,0 @@ - [ - * 'class' => 'yii\web\CacheSession', - * // 'cache' => 'mycache', - * ] - * ~~~ - * - * @property boolean $useCustomStorage Whether to use custom storage. This property is read-only. - * - * @author Qiang Xue - * @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]; - } -}