-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
095d934
commit 0dcd635
Showing
7 changed files
with
91 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Phikl\Cache\Adapter; | ||
|
||
use Phikl\Cache\Entry; | ||
use Psr\SimpleCache\CacheInterface; | ||
|
||
abstract class AbstractRemoteCacheAdapter implements CacheInterface | ||
{ | ||
/** | ||
* @param iterable<non-empty-string> $keys | ||
* | ||
* @return array<non-empty-string, Entry|null> | ||
*/ | ||
public function getMultiple(iterable $keys, mixed $default = null): array | ||
{ | ||
$entries = []; | ||
foreach ($keys as $key) { | ||
$entries[$key] = $this->get($key, $default); | ||
} | ||
|
||
return $entries; | ||
} | ||
|
||
/** | ||
* @param iterable<string, Entry> $values | ||
*/ | ||
public function setMultiple(iterable $values, \DateInterval|int|null $ttl = null): bool | ||
{ | ||
foreach ($values as $key => $value) { | ||
if (!$this->set($key, $value, $ttl)) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* @param iterable<string> $keys | ||
*/ | ||
public function deleteMultiple(iterable $keys): bool | ||
{ | ||
$success = true; | ||
foreach ($keys as $key) { | ||
if (!$this->delete($key)) { | ||
$success = false; | ||
} | ||
} | ||
|
||
return $success; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Cache/MemcachedServer.php → src/Cache/Adapter/MemcachedServer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Phikl\Cache; | ||
namespace Phikl\Cache\Adapter; | ||
|
||
final readonly class MemcachedServer | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 13 additions & 6 deletions
19
tests/Cache/MemcachedCacheTest.php → tests/Cache/Adapter/MemcachedCacheTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters