From b15e1268319618902c8893c41339f488b202ad44 Mon Sep 17 00:00:00 2001 From: User Date: Mon, 30 Dec 2024 02:37:57 +0300 Subject: [PATCH] 20241230#1 --- src/RedisStorage.php | 56 +++++++++++++++++++++++++++++++++++ src/RedisStorageInterface.php | 16 ++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/RedisStorage.php create mode 100644 src/RedisStorageInterface.php diff --git a/src/RedisStorage.php b/src/RedisStorage.php new file mode 100644 index 0000000..e90f689 --- /dev/null +++ b/src/RedisStorage.php @@ -0,0 +1,56 @@ +expire = $params['defaultExpire']; + unset($params['defaultExpire']); + } + $this->redis = new Redis($params); + if(!empty($database)) $this->redis->select($database); + } + + /** + * @throws RedisException + */ + public function set(string $key, mixed $value, mixed $option = null): void { + $this->redis->set($key, $value, $option); + } + + /** + * @throws RedisException + */ + public function setEx(string $key, mixed $value): void { + $this->redis->set($key, $value, $this->expire); + } + + /** + * @throws RedisException + */ + public function get(string $key) : mixed { + return $this->redis->get($key); + } + + /** + * @throws RedisException + */ + public function exists(mixed $key) : bool|int|Redis { + return $this->redis->exists($key); + } + + +} diff --git a/src/RedisStorageInterface.php b/src/RedisStorageInterface.php new file mode 100644 index 0000000..9e2e4b7 --- /dev/null +++ b/src/RedisStorageInterface.php @@ -0,0 +1,16 @@ +