diff --git a/src/Discord/Helpers/VoidCache.php b/src/Discord/Helpers/VoidCache.php new file mode 100644 index 000000000..282bb5b59 --- /dev/null +++ b/src/Discord/Helpers/VoidCache.php @@ -0,0 +1,66 @@ + + * + * This file is subject to the MIT license that is bundled + * with this source code in the LICENSE.md file. + */ + +namespace Discord\Helpers; + +use Psr\SimpleCache\CacheInterface; + +/** + * The cache that always be null/void + */ +class VoidCache implements CacheInterface +{ + public function get(string $key, mixed $default = null): mixed + { + return $default; + } + + public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool + { + return true; + } + + public function delete(string $key): bool + { + return true; + } + + public function getMultiple(iterable $keys, mixed $default = null): iterable + { + $result = []; + + foreach ($keys as $key) { + $result[$key] = $default; + } + + return $result; + } + + public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool + { + return true; + } + + public function deleteMultiple(iterable $keys): bool + { + return true; + } + + public function clear(): bool + { + return true; + } + + public function has(string $key): bool + { + return false; + } +}