index/src/Cache/Memcached/MemcachedProviderInfo.php
2024-04-10 22:23:34 +00:00

87 lines
1.9 KiB
PHP

<?php
// MemcachedProviderInfo.php
// Created: 2024-04-10
// Updated: 2024-04-10
namespace Index\Cache\Memcached;
use InvalidArgumentException;
use Index\Cache\ICacheProviderInfo;
/**
* Represents Memcached provider info.
*/
class MemcachedProviderInfo implements ICacheProviderInfo {
public function __construct(
private array $endPoints,
private string $prefixKey,
private string $persistName,
private bool $useBinaryProto,
private bool $enableCompression,
private bool $tcpNoDelay,
) {}
/**
* Gets server endpoints.
*
* @return array
*/
public function getEndPoints(): array {
return $this->endPoints;
}
/**
* A prefix that gets applied to every key.
*
* @return string
*/
public function getPrefixKey(): string {
return $this->prefixKey;
}
/**
* Whether the connection should be persistent.
*
* @return bool
*/
public function isPersistent(): bool {
return $this->persistName !== '';
}
/**
* Name of persistent connection, will return null if disabled.
*
* @return ?string
*/
public function getPersistentName(): ?string {
return $this->persistName === '' ? null : $this->persistName;
}
/**
* Whether the binary protocol should be used rather than ASCII.
*
* @return bool
*/
public function shouldUseBinaryProtocol(): bool {
return $this->useBinaryProto;
}
/**
* Whether compression should be applied.
*
* @return bool
*/
public function shouldEnableCompression(): bool {
return $this->enableCompression;
}
/**
* Whether nagle's algorithm should be disabled on the connection.
*
* @return bool
*/
public function shouldTcpNoDelay(): bool {
return $this->tcpNoDelay;
}
}