public static function get_add_store_form($plugin) {
        global $CFG; // Needed for includes.
        $plugins = core_component::get_plugin_list('cachestore');
        if (!array_key_exists($plugin, $plugins)) {
            throw new coding_exception('Invalid cache plugin used when trying to create an edit form.');
        }
        $plugindir = $plugins[$plugin];
        $class = 'cachestore_addinstance_form';
        if (file_exists($plugindir.'/addinstanceform.php')) {
            require_once($plugindir.'/addinstanceform.php');
            if (class_exists('cachestore_'.$plugin.'_addinstance_form')) {
                $class = 'cachestore_'.$plugin.'_addinstance_form';
                if (!array_key_exists('cachestore_addinstance_form', class_parents($class))) {
                    throw new coding_exception('Cache plugin add instance forms must extend cachestore_addinstance_form');
                }
            }
        }

        $locks = self::get_possible_locks_for_stores($plugindir, $plugin);

        $url = new moodle_url('/cache/admin.php', array('action' => 'addstore'));
        return new $class($url, array('plugin' => $plugin, 'store' => null, 'locks' => $locks));
    }