Skip to content

Commit

Permalink
Merge branch '2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Jan 19, 2018
2 parents 22e3f45 + b309cc0 commit d1c1856
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
7 changes: 6 additions & 1 deletion .platform.app.yaml
Expand Up @@ -18,7 +18,11 @@ build:
# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand
# side is in the form `<service name>:<endpoint name>`.
relationships:
database: "mysqldb:mysql"
database: 'mysqldb:mysql'
rediscache: 'rediscache:redis'
# If you wish to have a separate Redis instance for sessions, uncomment
# this relationship and the corresponding service in .platform/services.yaml
#redissession: 'redissession:redis'

# The configuration of app when it is exposed to the web.
web:
Expand Down Expand Up @@ -80,3 +84,4 @@ runtime:
- xsl
- imagick
- readline
- redis
15 changes: 15 additions & 0 deletions .platform/services.yaml
@@ -1,3 +1,18 @@
mysqldb:
type: mysql:10.0
disk: 2048

# For use by Symfony Cache (used by eZ Platform SPI Persistence Cache)
rediscache:
type: 'redis:3.2'

# If you wish to have a separate Redis instance for sessions, uncomment
# this service and the corresponding relationship in .platform.app.yaml.
#redissession:
# type: 'redis:3.2'
#
# Alternatively if you have a requirement that sessions are persisted across server/redis restarts,
# have storage space to spare for this, and don't mind a bit slower instance type of redis
#redissession:
# type: redis-persistent:3.2
# disk: 1024
41 changes: 33 additions & 8 deletions app/config/env/platformsh.php
Expand Up @@ -24,7 +24,18 @@
$container->setParameter('cluster_database_name', 'cluster');
}

if (isset($relationships['cache'])) {
// Use Redis-based caching if possible.
if (isset($relationships['rediscache'])) {
foreach ($relationships['rediscache'] as $endpoint) {
if ($endpoint['scheme'] !== 'redis') {
continue;
}

$container->setParameter('cache_host', $endpoint['host']);
$container->setParameter('cache_redis_port', $endpoint['port']);
}
} elseif (isset($relationships['cache'])) {
// Fallback to memcached if here (deprecated, we will only handle redis here in the future)
foreach ($relationships['cache'] as $endpoint) {
if ($endpoint['scheme'] !== 'memcached') {
continue;
Expand All @@ -33,19 +44,33 @@
$container->setParameter('cache_host', $endpoint['host']);
$container->setParameter('cache_memcached_port', $endpoint['port']);
}
} elseif (isset($relationships['redis'])) {
foreach ($relationships['redis'] as $endpoint) {
}

// Use Redis-based sessions if possible. If a separate Redis instance
// is available, use that. If not, share a Redis instance with the
// Cache. (That should be safe to do except on especially high-traffic sites.)
if (isset($relationships['redissession'])) {
foreach ($relationships['redissession'] as $endpoint) {
if ($endpoint['scheme'] !== 'redis') {
continue;
}

$container->setParameter('cache_host', $endpoint['host']);
$container->setParameter('cache_redis_port', $endpoint['port']);
ini_set('session.save_handler', 'redis');
ini_set('session.save_path', sprintf('%s:%d', $endpoint['host'], $endpoint['port']));
}
} elseif (isset($relationships['rediscache'])) {
foreach ($relationships['redissession'] as $endpoint) {
if ($endpoint['scheme'] !== 'redis') {
continue;
}

ini_set('session.save_handler', 'redis');
ini_set('session.save_path', sprintf('%s:%d', $endpoint['host'], $endpoint['port']));
}
} else {
// Store session into /tmp.
ini_set('session.save_path', '/tmp/sessions');
}

// Disable PHPStormPass
$container->setParameter('ezdesign.phpstorm.enabled', false);

// Store session into /tmp.
ini_set('session.save_path', '/tmp/sessions');

0 comments on commit d1c1856

Please sign in to comment.