Initial commit: CloudOps infrastructure platform

This commit is contained in:
root
2026-04-09 19:58:57 +02:00
commit 1166a52f26
7762 changed files with 839452 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace Mautic\CacheBundle\Cache\Adapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
class FilesystemTagAwareAdapter extends TagAwareAdapter
{
public function __construct(?string $prefix, int $lifetime = 0, ?string $directory = null)
{
$prefix = 'app_cache_'.$prefix;
parent::__construct(
new \Symfony\Component\Cache\Adapter\FilesystemAdapter($prefix, $lifetime, $directory),
new \Symfony\Component\Cache\Adapter\FilesystemAdapter($prefix.'_tags')
);
}
}

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Mautic\CacheBundle\Cache\Adapter;
use Mautic\CacheBundle\Exceptions\InvalidArgumentException;
use Symfony\Component\Cache\Adapter\MemcachedAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
class MemcachedTagAwareAdapter extends TagAwareAdapter
{
public function __construct(array $servers, string $namespace, int $lifetime)
{
if (!isset($servers['servers'])) {
throw new InvalidArgumentException('Invalid memcached configuration. No servers specified.');
}
$options = array_key_exists('options', $servers) ? $servers['options'] : [];
$client = MemcachedAdapter::createConnection($servers['servers'], $options);
parent::__construct(
new MemcachedAdapter($client, $namespace, $lifetime),
new MemcachedAdapter($client, $namespace, $lifetime)
);
}
}

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Mautic\CacheBundle\Cache\Adapter;
use Symfony\Component\Cache\Adapter\RedisAdapter as SymfonyRedisAdapter;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
class RedisAdapter extends SymfonyRedisAdapter
{
use RedisAdapterTrait;
/**
* @param mixed[] $servers
*/
public function __construct(
#[Autowire(env: 'json:MAUTIC_CACHE_ADAPTER_REDIS')]
array $servers,
#[Autowire(env: 'string:MAUTIC_CACHE_PREFIX')]
string $namespace,
#[Autowire(env: 'int:MAUTIC_CACHE_LIFETIME')]
int $lifetime,
#[Autowire(env: 'bool:MAUTIC_REDIS_PRIMARY_ONLY')]
bool $primaryOnly)
{
parent::__construct($this->createClient($servers, $primaryOnly), $namespace, $lifetime);
}
}

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Mautic\CacheBundle\Cache\Adapter;
use Mautic\CacheBundle\Exceptions\InvalidArgumentException;
use Mautic\CoreBundle\Helper\PRedisConnectionHelper;
use Predis\Client;
trait RedisAdapterTrait
{
/**
* @param mixed[] $servers
*/
private function createClient(array $servers, bool $primaryOnly): Client
{
if (!isset($servers['dsn'])) {
throw new InvalidArgumentException('Invalid redis configuration. No server specified.');
}
$options = array_key_exists('options', $servers) ? $servers['options'] : [];
$options['primaryOnly'] = $primaryOnly;
return PRedisConnectionHelper::createClient(PRedisConnectionHelper::getRedisEndpoints($servers['dsn']), $options);
}
}

View File

@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Mautic\CacheBundle\Cache\Adapter;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
class RedisTagAwareAdapter extends TagAwareAdapter
{
use RedisAdapterTrait;
/**
* @param mixed[] $servers
*/
public function __construct(
#[Autowire(env: 'json:MAUTIC_CACHE_ADAPTER_REDIS')]
array $servers,
#[Autowire(env: 'string:MAUTIC_CACHE_PREFIX')]
string $namespace,
#[Autowire(env: 'int:MAUTIC_CACHE_LIFETIME')]
int $lifetime,
#[Autowire(env: 'bool:MAUTIC_REDIS_PRIMARY_ONLY')]
bool $primaryOnly)
{
$client = $this->createClient($servers, $primaryOnly);
parent::__construct(
new RedisAdapter($client, $namespace, $lifetime),
new RedisAdapter($client, $namespace.'.tags.', $lifetime)
);
}
}