klsoft / yii3-cache-session-handler
The package implements the SessionHandlerInterface using the PSR-16 cache for storage
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/klsoft/yii3-cache-session-handler
Requires
- php: >=8.1
- psr/simple-cache: ^2.0|^3.0
README
The package implements the SessionHandlerInterface using the PSR-16 cache for storage.
See also:
- YII3-CACHE-REDIS - The package provides the PSR-16 cache using the Redis PHP extension
Requirement
- PHP 8.1 or higher.
Installation
composer require klsoft/yii3-cache-session-handler
How to use
Configure the SessionInterface.
Example:
use Yiisoft\Session\SessionInterface; use Yiisoft\Session\Session; use Klsoft\Yii3CacheSessionHandler\SessionHandler; use Yiisoft\Cache\CacheInterface; use Yiisoft\Cache\Cache; use Klsoft\Yii3CacheRedis\RedisCache; return [ // ... SessionInterface::class => [ 'class' => Session::class, '__construct()' => [ 'options' => $params['session']['options'] ?? [], 'handler' => new SessionHandler( new RedisCache( new Redis([ 'host' => $params['redisHost'], 'port' => $params['redisPort'], 'database' => $params['redisDatabaseSession'] ]) ) ) ] ], CacheInterface::class => [ 'class' => Cache::class, '__construct()' => [ 'handler' => new RedisCache( new Redis([ 'host' => $params['redisHost'], 'port' => $params['redisPort'], 'database' => $params['redisDatabaseCache'] ]) ) ] ], ];