Commit 872bb1aa authored by Henning Leutz's avatar Henning Leutz 🥋

feat: Mongo Driver for normal Cache

parent 63f2ac49
......@@ -57,7 +57,8 @@ QUI::$Ajax->registerFunction(
'apc',
'filesystem',
'redis',
'memcache'
'memcache',
'mongo'
], 0);
if (isset($params['handlers'][$cacheType])) {
......
......@@ -27,6 +27,9 @@
<conf name="redis">
<type><![CDATA[bool]]></type>
</conf>
<conf name="mongo">
<type><![CDATA[bool]]></type>
</conf>
</section>
<section name="apc">
......@@ -148,6 +151,9 @@
<option value="redis">
<locale group="quiqqer/quiqqer" var="quiqqer.settings.cache.handler.redis"/>
</option>
<option value="mongo">
<locale group="quiqqer/quiqqer" var="quiqqer.settings.cache.handler.mongo"/>
</option>
</select>
</settings>
......@@ -233,6 +239,38 @@
</description>
</input>
</settings>
<settings title="mongo" name="mongo">
<title>
<locale group="quiqqer/quiqqer" var="quiqqer.settings.mongo.title"/>
</title>
<input conf="mongo.host" type="text" placeholder="localhost">
<text>
<locale group="quiqqer/quiqqer" var="quiqqer.settings.mongo.server"/>
</text>
</input>
<input conf="mongo.database" type="text" placeholder="local">
<text>
<locale group="quiqqer/quiqqer" var="quiqqer.settings.mongo.database"/>
</text>
</input>
<input conf="mongo.collection" type="text" placeholder="quiqqer.cache">
<text>
<locale group="quiqqer/quiqqer" var="quiqqer.settings.mongo.collection"/>
</text>
</input>
<input conf="mongo.username" type="text">
<text>
<locale group="quiqqer/quiqqer" var="quiqqer.settings.mongo.username"/>
</text>
</input>
<input conf="mongo.password" type="text">
<text>
<locale group="quiqqer/quiqqer" var="quiqqer.settings.mongo.password"/>
</text>
</input>
</settings>
</category>
<category name="longtime" require="controls/cache/LongTime">
......
......@@ -99,12 +99,14 @@ define('controls/cache/General', [
RedisTable = Elm.querySelector('[name="general.redis"]').getParent('table'),
APCTable = Elm.querySelector('[name="apc.namespace"]').getParent('table'),
MemTable = Elm.querySelector('[name="memcache.servers"]').getParent('table'),
MongoTable = Elm.querySelector('[name="mongo.host"]').getParent('table'),
FileTable = Elm.querySelector('[name="filesystem.path"]').getParent('table');
RedisTable.setStyle('display', 'none');
APCTable.setStyle('display', 'none');
MemTable.setStyle('display', 'none');
FileTable.setStyle('display', 'none');
MongoTable.setStyle('display', 'none');
switch (CacheType.value) {
case 'apc':
......@@ -119,6 +121,10 @@ define('controls/cache/General', [
RedisTable.setStyle('display', null);
break;
case 'mongo':
MongoTable.setStyle('display', null);
break;
default:
case 'filesystem':
FileTable.setStyle('display', null);
......
......@@ -203,6 +203,14 @@ class Manager
} catch (Stash\Exception\RuntimeException $Exception) {
}
break;
case 'mongo':
try {
\array_unshift($handlers, self::getDriver([], 'mongo'));
} catch (Stash\Exception\RuntimeException $Exception) {
}
break;
}
}
......@@ -345,6 +353,54 @@ class Manager
} catch (Stash\Exception\RuntimeException $Exception) {
}
break;
case 'mongo':
if (!class_exists('\MongoDB\Client')) {
QUI\System\Log::write(
'Mongo DB Driver not found.
Please install MongoDB\Client (php MongoDB extension) or don\'t use MongoDB as long term cache',
QUI\System\Log::LEVEL_ALERT
);
} else {
$conf = $Config->get('mongo');
$host = 'localhost';
$database = 'local';
$collection = 'quiqqer.cache';
// database server
if (!empty($conf['host'])) {
$host = $conf['host'];
}
if (!empty($conf['database'])) {
$database = $conf['database'];
}
if (!empty($conf['collection'])) {
$collection = $conf['collection'];
}
if (\strpos($host, 'mongodb://') === false) {
$host = 'mongodb://'.$host;
}
if (!empty($conf['username']) && !empty($conf['password'])) {
$Client = new \MongoDB\Client($host, [
"username" => $conf['username'],
"password" => $conf['password']
]);
} else {
$Client = new \MongoDB\Client($host);
}
return new QuiqqerMongoDriver([
'mongo' => $Client,
'database' => $database,
'collection' => $collection
]);
}
break;
}
......
......@@ -2669,7 +2669,7 @@
<de><![CDATA[Dateisystem]]></de>
</locale>
<locale name="quiqqer.settings.longtime.mongo">
<de><![CDATA[Mongo-DB]]></de>
<de><![CDATA[MongoDB]]></de>
</locale>
<locale name="quiqqer.settings.longtime.redis">
<de><![CDATA[Redis]]></de>
......@@ -2709,22 +2709,22 @@
]]></de>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.title">
<de><![CDATA[Langzeitcache mit einer Mongo-DB]]></de>
<de><![CDATA[Langzeitcache mit einer MongoDB]]></de>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.server">
<de><![CDATA[MongoDB Server]]></de>
<de><![CDATA[Server]]></de>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.database">
<de><![CDATA[MongoDB Datenbank]]></de>
<de><![CDATA[Datenbank]]></de>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.username">
<de><![CDATA[MongoDB Bentzername]]></de>
<de><![CDATA[Bentzername]]></de>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.password">
<de><![CDATA[MongoDB Passwort]]></de>
<de><![CDATA[Passwort]]></de>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo_collection.server">
<de><![CDATA[MongoDB Collection]]></de>
<de><![CDATA[Collection]]></de>
</locale>
<locale name="quiqqer.settings.cache.clear.quiqqer">
......@@ -3191,6 +3191,9 @@
<locale name="quiqqer.settings.cache.handler.filesystem">
<de><![CDATA[Dateisystem]]></de>
</locale>
<locale name="quiqqer.settings.cache.handler.mongo">
<de><![CDATA[MongoDB]]></de>
</locale>
<locale name="quiqqer.settings.cache.handler.apc">
<de><![CDATA[APC]]></de>
</locale>
......@@ -3250,6 +3253,25 @@
Falls kein Pfad angegeben wurde, wird im standard VAR Ordner ein cache/stack/ Verzeichnis angelegt
]]></de>
</locale>
<locale name="quiqqer.settings.mongo.title">
<de><![CDATA[MongoDB Cache Einstellungen]]></de>
</locale>
<locale name="quiqqer.settings.mongo.server">
<de><![CDATA[Server]]></de>
</locale>
<locale name="quiqqer.settings.mongo.database">
<de><![CDATA[Datenbank]]></de>
</locale>
<locale name="quiqqer.settings.mongo.collection">
<de><![CDATA[Collection Name]]></de>
</locale>
<locale name="quiqqer.settings.mongo.username">
<de><![CDATA[Benutzername]]></de>
</locale>
<locale name="quiqqer.settings.mongo.password">
<de><![CDATA[Passwort]]></de>
</locale>
<locale name="quiqqer.settings.gui">
<de><![CDATA[Oberfläche (GUI)]]></de>
</locale>
......
......@@ -2612,7 +2612,7 @@ You can also ignore the console user permissions check with '--ignore-file-permi
<en><![CDATA[File system]]></en>
</locale>
<locale name="quiqqer.settings.longtime.mongo">
<en><![CDATA[Mongo-DB]]></en>
<en><![CDATA[MongoDB]]></en>
</locale>
<locale name="quiqqer.settings.longtime.redis">
<en><![CDATA[Redis]]></en>
......@@ -2655,21 +2655,40 @@ You can also ignore the console user permissions check with '--ignore-file-permi
<en><![CDATA[Long term cache with a Mongo DB]]></en>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.database">
<en><![CDATA[MongoDB Database]]></en>
<en><![CDATA[Database]]></en>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.server">
<en><![CDATA[MongoDB Server]]></en>
<en><![CDATA[Server]]></en>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.username">
<en><![CDATA[MongoDB Username]]></en>
<en><![CDATA[Username]]></en>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo.password">
<en><![CDATA[MongoDB Password]]></en>
<en><![CDATA[Password]]></en>
</locale>
<locale name="quiqqer.settings.longTimeCache.mongo_collection.server">
<en><![CDATA[MongoDB Collection]]></en>
<en><![CDATA[Collection]]></en>
</locale>
<locale name="quiqqer.settings.mongo.title">
<en><![CDATA[MongoDB Cache settings]]></en>
</locale>
<locale name="quiqqer.settings.mongo.server">
<en><![CDATA[Server]]></en>
</locale>
<locale name="quiqqer.settings.mongo.database">
<en><![CDATA[Database]]></en>
</locale>
<locale name="quiqqer.settings.mongo.collection">
<en><![CDATA[Collection name]]></en>
</locale>
<locale name="quiqqer.settings.mongo.username">
<en><![CDATA[Username]]></en>
</locale>
<locale name="quiqqer.settings.mongo.password">
<en><![CDATA[Password]]></en>
</locale>
<locale name="quiqqer.settings.cache.quiqqer.title">
<en><![CDATA[QUIQQER System Cache]]></en>
</locale>
......@@ -3093,6 +3112,9 @@ You can also ignore the console user permissions check with '--ignore-file-permi
<locale name="quiqqer.settings.cache.handler.filesystem">
<en><![CDATA[Filesystem]]></en>
</locale>
<locale name="quiqqer.settings.cache.handler.mongo">
<en><![CDATA[MongoDB]]></en>
</locale>
<locale name="quiqqer.settings.cache.handler.apc">
<en><![CDATA[APC]]></en>
</locale>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment