Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cache fixes #887

Merged
merged 3 commits into from
Jun 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions system/blueprints/config/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,54 @@ form:
auto: Auto detect
file: File
apc: APC
xcache: XCache
memcache: MemCache
apcu: APCu
xcache: Xcache
memcache: Memcache
memcached: Memcached
wincache: WinCache
redis: Redis

cache.memcache.server:
type: text
size: medium
label: PLUGIN_ADMIN.MEMCACHE_SERVER
help: PLUGIN_ADMIN.MEMCACHE_SERVER_HELP
placeholder: "localhost"

cache.memcache.port:
type: text
size: small
label: PLUGIN_ADMIN.MEMCACHE_PORT
help: PLUGIN_ADMIN.MEMCACHE_PORT_HELP
placeholder: "11211"

cache.memcached.server:
type: text
size: medium
label: PLUGIN_ADMIN.MEMCACHED_SERVER
help: PLUGIN_ADMIN.MEMCACHED_SERVER_HELP
placeholder: "localhost"

cache.memcached.port:
type: text
size: small
label: PLUGIN_ADMIN.MEMCACHED_PORT
help: PLUGIN_ADMIN.MEMCACHED_PORT_HELP
placeholder: "11211"

cache.redis.server:
type: text
size: medium
label: PLUGIN_ADMIN.REDIS_SERVER
help: PLUGIN_ADMIN.REDIS_SERVER_HELP
placeholder: "localhost"

cache.redis.port:
type: text
size: small
label: PLUGIN_ADMIN.REDIS_PORT
help: PLUGIN_ADMIN.REDIS_PORT_HELP
placeholder: "6379"

cache.prefix:
type: text
Expand Down Expand Up @@ -510,7 +555,6 @@ form:
validate:
type: bool


twig:
type: section
title: PLUGIN_ADMIN.TWIG_TEMPLATING
Expand Down
9 changes: 8 additions & 1 deletion system/src/Grav/Common/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,18 @@ public function getCacheDriver()
$driver->setMemcache($memcache);
break;

case 'memcached':
$memcached = new \Memcached();
$memcached->connect($this->config->get('system.cache.memcached.server', 'localhost'),
$this->config->get('system.cache.memcached.port', 11211));
$driver = new DoctrineCache\MemcachedCache();
$driver->setMemcached($memcached);
break;

case 'redis':
$redis = new \Redis();
$redis->connect($this->config->get('system.cache.redis.server', 'localhost'),
$this->config->get('system.cache.redis.port', 6379));

$driver = new DoctrineCache\RedisCache();
$driver->setRedis($redis);
break;
Expand Down