Skip to content

Commit

Permalink
Merge branch 'MDL-48468' of https://github.com/mr-russ/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Nov 2, 2016
2 parents 2f8b51f + fd7bb5a commit c6ae02c
Show file tree
Hide file tree
Showing 9 changed files with 795 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cache/stores/redis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Redis Cache Store for Moodle
============================

A Moodle cache store plugin for [Redis](http://redis.io).

This plugin requires the [PhpRedis](https://github.com/nicolasff/phpredis) extension. The PhpRedis extension can be installed via PECL with `pecl install redis`.
52 changes: 52 additions & 0 deletions cache/stores/redis/addinstanceform.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Redis Cache Store - Add instance form
*
* @package cachestore_redis
* @copyright 2013 Adam Durana
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot.'/cache/forms.php');

/**
* Form for adding instance of Redis Cache Store.
*
* @copyright 2013 Adam Durana
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cachestore_redis_addinstance_form extends cachestore_addinstance_form {
/**
* Builds the form for creating an instance.
*/
protected function configuration_definition() {
$form = $this->_form;

$form->addElement('text', 'server', get_string('server', 'cachestore_redis'), array('size' => 24));
$form->setType('server', PARAM_TEXT);
$form->addHelpButton('server', 'server', 'cachestore_redis');
$form->addRule('server', get_string('required'), 'required');

$form->addElement('text', 'prefix', get_string('prefix', 'cachestore_redis'), array('size' => 16));
$form->setType('prefix', PARAM_TEXT); // We set to text but we have a rule to limit to alphanumext.
$form->addHelpButton('prefix', 'prefix', 'cachestore_redis');
$form->addRule('prefix', get_string('prefixinvalid', 'cachestore_redis'), 'regex', '#^[a-zA-Z0-9\-_]+$#');
}
}
36 changes: 36 additions & 0 deletions cache/stores/redis/lang/en/cachestore_redis.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Redis Cache Store - English language strings
*
* @package cachestore_redis
* @copyright 2013 Adam Durana
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

$string['pluginname'] = 'Redis';
$string['prefix'] = 'Key prefix';
$string['prefix_help'] = 'This prefix is used for all key names on the Redis server.
* If you only have one Moodle instance using this server, you can leave this value default.
* Due to key length restrictions, a maximum of 5 characters is permitted.';
$string['prefixinvalid'] = 'Invalid prefix. You can only use a-z A-Z 0-9-_.';
$string['test_server'] = 'Test Server';
$string['test_server_desc'] = 'Redis server to use for testing.';
$string['server'] = 'Server';
$string['server_help'] = 'This sets the hostname or IP address of the Redis server to use.';
Loading

0 comments on commit c6ae02c

Please sign in to comment.