Last active
February 26, 2020 08:56
-
-
Save kamiazya/30271e905c06bf88279b796067111aa7 to your computer and use it in GitHub Desktop.
CakePHP 2.x系からRedisを利用するためのDockerfileとcore.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Cache::config('default', array( | |
'engine' => 'Redis', | |
'prefix' => null, | |
'duration' => 3600, | |
'probability' => 100, | |
'server' => env('REDIS_HOST'), | |
'port' => env('REDIS_PORT'), | |
'persistent' => true, | |
'compress' => false, | |
)); | |
$engine = 'Redis'; | |
// In development mode, caches should expire quickly. | |
$duration = '+999 days'; | |
if (Configure::read('debug') > 0) { | |
$duration = '+10 seconds'; | |
} | |
// Prefix each application on the same server with a different string, to avoid Memcache and APC conflicts. | |
$prefix = 'app_'; | |
/** | |
* Configure the cache used for general framework caching. Path information, | |
* object listings, and translation cache files are stored with this configuration. | |
*/ | |
Cache::config('_cake_core_', array( | |
'engine' => $engine, | |
'prefix' => $prefix . 'cake_core_', | |
'path' => CACHE . 'persistent' . DS, | |
'server' => env('REDIS_HOST'), | |
'port' => env('REDIS_PORT'), | |
'serialize' => ($engine === 'File'), | |
'duration' => $duration | |
)); | |
/** | |
* Configure the cache for model and datasource caches. This cache configuration | |
* is used to store schema descriptions, and table listings in connections. | |
*/ | |
Cache::config('_cake_model_', array( | |
'engine' => $engine, | |
'prefix' => $prefix . 'cake_model_', | |
'path' => CACHE . 'models' . DS, | |
'server' => env('REDIS_HOST'), | |
'port' => env('REDIS_PORT'), | |
'serialize' => ($engine === 'File'), | |
'duration' => $duration | |
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:7.2.1-fpm-alpine3.7 | |
# Redisとの連携部分の定義 | |
ENV REDIS_HOST redis | |
ENV REDIS_PORT 6379 | |
# redis拡張をインストール | |
ENV PHPREDIS_VERSION 3.1.2 | |
RUN docker-php-source extract \ | |
&& curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz \ | |
&& tar xfz /tmp/redis.tar.gz \ | |
&& rm -r /tmp/redis.tar.gz \ | |
&& mv phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \ | |
&& docker-php-ext-install redis \ | |
&& docker-php-source delete | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment