Skip to content

Instantly share code, notes, and snippets.

@juban
Last active February 8, 2023 20:15
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save juban/6e3bd1eb6a75167a813fc057953b917d to your computer and use it in GitHub Desktop.
Save juban/6e3bd1eb6a75167a813fc057953b917d to your computer and use it in GitHub Desktop.
Redis configuration for Craft CMS
<?php
/**
* Yii Application Config
*
* Edit this file at your own risk!
*
* The array returned by this file will get merged with
* vendor/craftcms/cms/src/config/app/main.php and [web|console].php, when
* Craft's bootstrap script is defining the configuration for the entire
* application.
*
* You can define custom modules and system components, and even override the
* built-in system components.
*/
return [
'components' => [
'cache' => [
'class' => 'yii\redis\Cache',
'defaultDuration' => 86400,
'keyPrefix' => getenv('REDIS_KEYPREFIX').'_cache_',
'redis' => [
'hostname' => getenv('REDIS_HOST'),
'port' => getenv('REDIS_PORT'),
'database' => 0,
'password' => getenv('REDIS_PASSWORD') // Optional
]
],
'session' => [
'class' => 'yii\redis\Session',
'as sessionBehavior' => [
'class' => 'craft\behaviors\SessionBehavior'
],
'keyPrefix' => getenv('REDIS_KEYPREFIX').'_session_',
'redis' => [
'hostname' => getenv('REDIS_HOST'),
'port' => getenv('REDIS_PORT'),
'database' => 1,
'password' => getenv('REDIS_PASSWORD') // Optional
]
],
],
'modules' => [
'siteModule' => \modules\Module::class,
],
'bootstrap' => [
'siteModule',
],
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment