Permalink
Browse files

MDL-25290 cache_file: Added default file cache store

  • Loading branch information...
Sam Hemelryk
Sam Hemelryk committed Sep 10, 2012
1 parent d6a1f63 commit 62704f33d4e99264e97b6ade92154d30aa9cf2d3
@@ -0,0 +1,59 @@
+<?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/>.
+
+/**
+ * The library file for the file cache store.
+ *
+ * This file is part of the file cache store, it contains the API for interacting with an instance of the store.
+ * This is used as a default cache store within the Cache API. It should never be deleted.
+ *
+ * @package cache_file
+ * @category cache
+ * @copyright 2012 Sam Hemelryk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+require_once($CFG->dirroot.'/cache/forms.php');
+require_once($CFG->dirroot.'/cache/stores/file/lib.php');
+
+/**
+ * Form for adding a file instance.
+ *
+ * @copyright 2012 Sam Hemelryk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class cache_store_file_addinstance_form extends cache_store_addinstance_form {
+
+ /**
+ * Adds the desired form elements.
+ */
+ protected function configuration_definition() {
+ $form = $this->_form;
+
+ $form->addElement('text', 'path', get_string('path', 'cache_file'));
+ $form->setType('path', PARAM_SAFEPATH);
+ $form->addHelpButton('path', 'path', 'cache_file');
+
+ $form->addElement('checkbox', 'autocreate', get_string('autocreate', 'cache_file'));
+ $form->setType('autocreate', PARAM_BOOL);
+ $form->addHelpButton('autocreate', 'autocreate', 'cache_file');
+ $form->disabledIf('autocreate', 'path', 'eq', '');
+
+ $form->addElement('checkbox', 'prescan', get_string('prescan', 'cache_file'));
+ $form->setType('prescan', PARAM_BOOL);
+ $form->addHelpButton('prescan', 'prescan', 'cache_file');
+ }
+}
@@ -0,0 +1,37 @@
+<?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/>.
+
+/**
+ * The library file for the file cache store.
+ *
+ * This file is part of the file cache store, it contains the API for interacting with an instance of the store.
+ * This is used as a default cache store within the Cache API. It should never be deleted.
+ *
+ * @package cache_file
+ * @category cache
+ * @copyright 2012 Sam Hemelryk
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$string['autocreate'] = 'Auto create directory';
+$string['autocreate_help'] = 'If enabled the directory specified in path will be automatically created if it does not already exist.';
+$string['path'] = 'Cache path';
+$string['path_help'] = 'The directory that should be used to store files for this cache store. If left blank (default) a directory will be automatically created in the moodledata directory. This can be used to point a file store towards a directory on a better performing drive (such as one in memory).';
+$string['pluginname'] = 'File cache';
+$string['prescan'] = 'Prescan directory';
+$string['prescan_help'] = 'If enabled the directory is scanned when the cache is first used and requests for files are first checked against the scan data. This can help if you have a slow file system and are finding that file operations are causing you a bottle neck.';
Oops, something went wrong.

0 comments on commit 62704f3

Please sign in to comment.