Skip to content

Instantly share code, notes, and snippets.

@tonyclemmey
Forked from juban/app.php
Created November 21, 2020 00:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyclemmey/37d9d1770fe8bae6267e3cb7dcf51006 to your computer and use it in GitHub Desktop.
Save tonyclemmey/37d9d1770fe8bae6267e3cb7dcf51006 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