This commit is contained in:
the-djmaze 2024-03-31 21:06:39 +02:00
parent a424c6a52a
commit 8e0303f065
3 changed files with 146 additions and 0 deletions

View file

@ -0,0 +1,34 @@
<?php
class CacheAPCuPlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'Cache APCu',
VERSION = '2.36',
RELEASE = '2024-03-22',
REQUIRED = '2.36.0',
CATEGORY = 'Cache',
DESCRIPTION = 'Cache handler using PHP APCu';
public function Init() : void
{
if (\MailSo\Base\Utils::FunctionsCallable(array('apcu_store', 'apcu_fetch', 'apcu_delete', 'apcu_clear_cache'))) {
$this->addHook('main.fabrica', 'MainFabrica');
}
}
public function Supported() : string
{
return \MailSo\Base\Utils::FunctionsCallable(array('apcu_store', 'apcu_fetch', 'apcu_delete', 'apcu_clear_cache'))
? ''
: 'PHP APCu not installed';
}
public function MainFabrica($sName, &$mResult)
{
if ('cache' == $sName) {
require_once __DIR__ . '/APCU.php';
$mResult = new \MailSo\Cache\Drivers\APCU;
}
}
}

View file

@ -0,0 +1,54 @@
<?php
class CacheMemcachePlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'Cache Memcache',
VERSION = '2.36',
RELEASE = '2024-03-22',
REQUIRED = '2.36.0',
CATEGORY = 'Cache',
DESCRIPTION = 'Cache handler using PHP Memcache or PHP Memcached';
public function Init() : void
{
if (\class_exists('Memcache',false) || \class_exists('Memcached',false)) {
$this->addHook('main.fabrica', 'MainFabrica');
}
}
public function Supported() : string
{
return (\class_exists('Memcache',false) || \class_exists('Memcached',false))
? ''
: 'PHP Memcache/Memcached not installed';
}
public function MainFabrica($sName, &$mResult)
{
if ('cache' == $sName) {
require_once __DIR__ . '/Memcache.php';
$mResult = new \MailSo\Cache\Drivers\Memcache(
$this->Config()->Get('plugin', 'host', '127.0.0.1'),
(int) $this->Config()->Get('plugin', 'port', 11211)
);
}
}
protected function configMapping() : array
{
return array(
\RainLoop\Plugins\Property::NewInstance('host')->SetLabel('Host')
->SetDescription('Hostname of the memcache server')
->SetDefaultValue('127.0.0.1'),
\RainLoop\Plugins\Property::NewInstance('port')->SetLabel('Port')
->SetDescription('Port of the memcache server')
->SetDefaultValue(11211)
/*
,\RainLoop\Plugins\Property::NewInstance('password')->SetLabel('Password')
->SetType(\RainLoop\Enumerations\PluginPropertyType::PASSWORD)
->SetDefaultValue('')
*/
);
}
}

View file

@ -0,0 +1,58 @@
<?php
class CacheRedisPlugin extends \RainLoop\Plugins\AbstractPlugin
{
// use \MailSo\Log\Inherit;
const
NAME = 'Cache Redis',
VERSION = '2.36.1',
RELEASE = '2024-03-31',
REQUIRED = '2.36.0',
CATEGORY = 'Cache',
DESCRIPTION = 'Cache handler using Redis';
public function Init() : void
{
spl_autoload_register(function($sClassName){
$file = __DIR__ . DIRECTORY_SEPARATOR . strtr($sClassName, '\\', DIRECTORY_SEPARATOR) . '.php';
is_file($file) && include_once $file;
});
if (\class_exists('Predis\Client')) {
$this->addHook('main.fabrica', 'MainFabrica');
}
}
public function Supported() : string
{
return '';
}
public function MainFabrica($sName, &$mResult)
{
if ('cache' == $sName) {
require_once __DIR__ . '/Redis.php';
$mResult = new \MailSo\Cache\Drivers\Redis(
$this->Config()->Get('plugin', 'host', '127.0.0.1'),
(int) $this->Config()->Get('plugin', 'port', 6379)
);
}
}
protected function configMapping() : array
{
return array(
\RainLoop\Plugins\Property::NewInstance('host')->SetLabel('Host')
->SetDescription('Hostname of the redis server')
->SetDefaultValue('127.0.0.1'),
\RainLoop\Plugins\Property::NewInstance('port')->SetLabel('Port')
->SetDescription('Port of the redis server')
->SetDefaultValue(6379)
/*
,\RainLoop\Plugins\Property::NewInstance('password')->SetLabel('Password')
->SetType(\RainLoop\Enumerations\PluginPropertyType::PASSWORD)
->SetDefaultValue('')
*/
);
}
}