Initial Commit

This commit is contained in:
Netkas 2023-06-04 14:23:51 -04:00
parent 93a0b9be02
commit 6e599b2c0c
No known key found for this signature in database
GPG key ID: 5DAF58535614062B
99 changed files with 10836 additions and 4 deletions

View file

@ -0,0 +1,162 @@
<?php
namespace FederationLib\Classes\Configuration;
class CacheServerConfiguration
{
/**
* @var string
*/
private string $name;
/**
* @var bool
*/
private bool $enabled;
/**
* @var string|null
*/
private ?string $host;
/**
* @var int|null
*/
private ?int $port;
/**
* @var string|null
*/
private ?string $driver;
/**
* @var int|null
*/
private ?int $priority;
/**
* @var string|null
*/
private ?string $username;
/**
* @var string|null
*/
private ?string $password;
/**
* @var string|null
*/
private ?string $database;
/**
* @var int|null
*/
private ?int $reconnect_interval;
/**
* CacheServerConfiguration constructor.
*
* @param array $configuration
*/
public function __construct(string $name, array $configuration)
{
$this->name = $configuration['name'] ?? $name;
$this->enabled = $configuration['enabled'] ?? false;
$this->host = $configuration['host'] ?? null;
$this->port = $configuration['port'] ?? null;
$this->driver = $configuration['driver'] ?? null;
$this->priority = $configuration['priority'] ?? null;
$this->username = $configuration['username'] ?? null;
$this->password = $configuration['password'] ?? null;
$this->database = $configuration['database'] ?? null;
$this->reconnect_interval = $configuration['reconnect_interval'] ?? null;
}
/**
* Returns the name of the cache server
*
* @return string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* Returns whether the cache server is enabled
*
* @return bool
*/
public function getEnabled(): bool
{
return $this->enabled ?? false;
}
/**
* Returns the host of the cache server
*
* @return string|null
*/
public function getHost(): ?string
{
return $this->host;
}
/**
* @return int|null
*/
public function getPort(): ?int
{
return $this->port;
}
/**
* @return string|null
*/
public function getDriver(): ?string
{
return $this->driver;
}
/**
* @return int|null
*/
public function getPriority(): ?int
{
return $this->priority;
}
/**
* @return string|null
*/
public function getUsername(): ?string
{
return $this->username;
}
/**
* @return string|null
*/
public function getPassword(): ?string
{
return $this->password;
}
/**
* @return string|null
*/
public function getDatabase(): ?string
{
return $this->database;
}
/**
* @return int|null
*/
public function getReconnectInterval(): ?int
{
return $this->reconnect_interval;
}
}

View file

@ -0,0 +1,144 @@
<?php
namespace FederationLib\Classes\Configuration;
class CacheSystemConfiguration
{
/**
* @var bool
*/
private $client_objects_enabled;
/**
* @var int
*/
private $client_objects_ttl;
/**
* @var string
*/
private $client_objects_server_preference;
/**
* @var string
*/
private $client_objects_server_fallback;
/**
* @var bool
*/
private $peer_objects_enabled;
/**
* @var int
*/
private $peer_objects_ttl;
/**
* @var string
*/
private $peer_objects_server_preference;
/**
* @var string
*/
private $peer_objects_server_fallback;
/**
* CacheSystemConfiguration constructor.
*
* @param array $configuration
*/
public function __construct(array $configuration)
{
$this->client_objects_enabled = $configuration['cache_system.cache.client_objects_enabled'] ?? false;
$this->client_objects_ttl = $configuration['cache_system.cache.client_objects_ttl'] ?? 200;
$this->client_objects_server_preference = $configuration['cache_system.cache.client_objects_server_preference'] ?? 'any';
$this->client_objects_server_fallback = $configuration['cache_system.cache.client_objects_server_fallback'] ?? 'any';
$this->peer_objects_enabled = $configuration['cache_system.cache.peer_objects_enabled'] ?? false;
$this->peer_objects_ttl = $configuration['cache_system.cache.peer_objects_ttl'] ?? 200;
$this->peer_objects_server_preference = $configuration['cache_system.cache.peer_objects_server_preference'] ?? 'any';
$this->peer_objects_server_fallback = $configuration['cache_system.cache.peer_objects_server_fallback'] ?? 'any';
}
/**
* Returns True if client cache objects are enabled, false otherwise
*
* @return bool
*/
public function getClientObjectsEnabled(): bool
{
return $this->client_objects_enabled;
}
/**
* Returns the TTL for client cache objects
*
* @return int
*/
public function getClientObjectsTtl(): int
{
return $this->client_objects_ttl;
}
/**
* Returns the server preference to where client cache objects should be stored
*
* @return string
*/
public function getClientObjectsServerPreference(): string
{
return $this->client_objects_server_preference;
}
/**
* Returns the server fallback to where client cache objects should be stored
*
* @return string
*/
public function getClientObjectsServerFallback(): string
{
return $this->client_objects_server_fallback;
}
/**
* Returns True if peer cache objects are enabled, false otherwise
*
* @return bool
*/
public function getPeerObjectsEnabled(): bool
{
return $this->peer_objects_enabled;
}
/**
* Returns the TTL for peer cache objects
*
* @return int
*/
public function getPeerObjectsTtl(): int
{
return $this->peer_objects_ttl;
}
/**
* Returns the server preference to where peer cache objects should be stored
*
* @return string
*/
public function getPeerObjectsServerPreference(): string
{
return $this->peer_objects_server_preference;
}
/**
* Returns the server fallback to where peer cache objects should be stored
*
* @return string
*/
public function getPeerObjectsServerFallback(): string
{
return $this->peer_objects_server_fallback;
}
}