Skip to content

Commit c3ce026

Browse files
committed
Remove unnecessary compatibility layer for Memcached
1 parent a217ed0 commit c3ce026

File tree

10 files changed

+180
-343
lines changed

10 files changed

+180
-343
lines changed

src/Dashboards/Memcached/Compatibility/Memcache.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/Dashboards/Memcached/Compatibility/Memcached.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/Dashboards/Memcached/Compatibility/MemcachedCompatibilityInterface.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Dashboards/Memcached/Compatibility/MemcachedKeys.php

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/Dashboards/Memcached/Compatibility/PHPMem.php

Lines changed: 0 additions & 119 deletions
This file was deleted.

src/Dashboards/Memcached/MemcachedDashboard.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MemcachedDashboard implements DashboardInterface {
2525

2626
private int $current_server;
2727

28-
public Compatibility\Memcached|Compatibility\Memcache|Compatibility\PHPMem $memcached;
28+
public PHPMem $memcached;
2929

3030
/**
3131
* @var array<int, mixed>
@@ -42,7 +42,7 @@ public function __construct(private readonly Template $template) {
4242
public static function check(): bool {
4343
return extension_loaded('memcached') ||
4444
extension_loaded('memcache') ||
45-
class_exists(Compatibility\PHPMem::class);
45+
class_exists(PHPMem::class);
4646
}
4747

4848
/**
@@ -75,17 +75,13 @@ public function dashboardInfo(): array {
7575
*
7676
* @throws DashboardException
7777
*/
78-
public function connect(array $server): Compatibility\Memcached|Compatibility\Memcache|Compatibility\PHPMem {
78+
public function connect(array $server): PHPMem {
7979
$server['port'] ??= 11211;
8080

81-
if (extension_loaded('memcached')) {
82-
$memcached = new Compatibility\Memcached($server);
83-
} elseif (extension_loaded('memcache')) {
84-
$memcached = new Compatibility\Memcache($server);
85-
} elseif (class_exists(Compatibility\PHPMem::class)) {
86-
$memcached = new Compatibility\PHPMem($server);
81+
if (class_exists(PHPMem::class)) {
82+
$memcached = new PHPMem($server);
8783
} else {
88-
throw new DashboardException('Memcache(d) extension or PHPMem client is not installed.');
84+
throw new DashboardException('PHPMem client is not installed.');
8985
}
9086

9187
if (!$memcached->isConnected()) {

src/Dashboards/Memcached/MemcachedTrait.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717

1818
trait MemcachedTrait {
1919
private function panels(): string {
20-
if (extension_loaded('memcached') || extension_loaded('memcache')) {
21-
$memcached = extension_loaded('memcached') ? 'd' : '';
22-
$title = 'PHP Memcache'.$memcached.' extension v'.phpversion('memcache'.$memcached);
23-
} elseif (class_exists(Compatibility\PHPMem::class)) {
24-
$title = 'PHPMem v'.Compatibility\PHPMem::VERSION;
20+
if (class_exists(PHPMem::class)) {
21+
$title = 'PHPMem v'.PHPMem::VERSION;
2522
}
2623

2724
try {
@@ -162,7 +159,7 @@ public function saveKey(): void {
162159
$this->memcached->delete($old_key);
163160
}
164161

165-
$this->memcached->store($key, $value, $expire);
162+
$this->memcached->set($key, $value, $expire);
166163

167164
Http::redirect([], ['view' => 'key', 'ttl' => $expire, 'key' => $key]);
168165
}
@@ -241,7 +238,7 @@ private function mainDashboard(): string {
241238
if (isset($_POST['submit_import_key'])) {
242239
Helpers::import(
243240
fn (string $key): bool => $this->memcached->exists($key),
244-
fn (string $key, string $value, int $ttl): bool => $this->memcached->store($key, base64_decode($value), $ttl)
241+
fn (string $key, string $value, int $ttl): bool => $this->memcached->set($key, base64_decode($value), $ttl)
245242
);
246243
}
247244

0 commit comments

Comments
 (0)